FileDocCategorySizeDatePackage
Level2.javaAPI DocExample1238Wed Mar 05 15:53:16 GMT 2003com.jspservletcookbook

Level2

public class Level2 extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

        
         java.io.PrintWriter out = response.getWriter();
        out.println("<h2>Hello from Level 2</h2>");
        out.println("This text is included at Level 2.");
        //Include the JSP file named "level3.jsp"
       try{
         RequestDispatcher dispatcher = request.getRequestDispatcher("/level3.jsp");
        dispatcher.include(request, response);
     } catch (Exception se){
            
            String context_path = (String) request.getAttribute("javax.servlet.include.context_path");
            String servlet_path = (String) request.getAttribute("javax.servlet.include.servlet_path");
            String errMessage = new StringBuffer("Exception raised during Level2 servlet include:<br>").
                append("Context path: "+context_path+"<br>").
                append("Servlet path: "+servlet_path).toString();
            throw new ServletException(errMessage);
            
        }