FileDocCategorySizeDatePackage
ErrorPage.javaAPI DocExample1183Wed Mar 05 15:38:16 GMT 2003com.jspservletcookbook

ErrorPage

public class ErrorPage extends HttpServlet

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

        
        response.setContentType("text/html");
        java.io.PrintWriter out = response.getWriter();
       
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Error Page Servlet</title>");  
        out.println("</head>");
        out.println("<body>");
        out.println("<h2>Error Information</h2>");
        out.println("Regretably, an error occurred. Here is the information:<br><br>");
        Exception exception = (Exception) request.getAttribute("javax.servlet.error.exception");
        String servletName = (String) request.getAttribute("javax.servlet.error.servlet_name");
        out.println("The servlet name that generated the exception: "+servletName+"<br>");
        out.println("Exception message: "+exception.getMessage());
        out.println("</body>");
        out.println("</html>");
       
        out.close();