This example does not meet Oracle secure coding standards and modifications may be required to comply with the security practices and standards of your organization.

Source Code for ToJSPServlet Example

import javax.servlet.*;
import javax.servlet.http.*;

public class ToJSPServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    {
        try
        {
             // Set the attribute and Forward to hello.jsp
             request.setAttribute("servletName", "ServletToJSP");
             getServletConfig().getServletContext().getRequestDispatcher("/examples/jsp/jsptoserv/hello.jsp").forward(request, response);
        }
        catch(Exception ex)
        {
                ex.printStackTrace();
        }
    }
}