com.ora.jsp.servlets
Class ErrorDispatcherServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.ora.jsp.servlets.ErrorDispatcherServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ErrorDispatcherServlet
extends javax.servlet.http.HttpServlet

This class can be registered as an error handler for exceptions and status codes in the web application deployment description. It forwards to a JSP error page after setting all request attributes the JSP container uses to initialize the exception variable, as well as an attribute to contain the URI for the request that triggered the error handler.

Version:
1.0
Author:
Hans Bergsten, Gefion software
See Also:
Serialized Form

Field Summary
private  java.lang.String errorPage
           
private static java.lang.String HTTP_STATUS_CODE
           
private static java.lang.String JSP_ERROR_SOURCE
           
private static java.lang.String JSP_EXCEPTION
           
private static java.lang.String SERVLET_ERROR_SOURCE
           
private static java.lang.String SERVLET_EXCEPTION
           
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Constructor Summary
ErrorDispatcherServlet()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Calls doPost()
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Sets the request attributes for the exeception and request URI and forwards to the JSP error page.
 void init()
          Reads the "errorPage" init parameter and saves the value in an instance variable.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVLET_EXCEPTION

private static final java.lang.String SERVLET_EXCEPTION
See Also:
Constant Field Values

JSP_EXCEPTION

private static final java.lang.String JSP_EXCEPTION
See Also:
Constant Field Values

SERVLET_ERROR_SOURCE

private static final java.lang.String SERVLET_ERROR_SOURCE
See Also:
Constant Field Values

JSP_ERROR_SOURCE

private static final java.lang.String JSP_ERROR_SOURCE
See Also:
Constant Field Values

HTTP_STATUS_CODE

private static final java.lang.String HTTP_STATUS_CODE
See Also:
Constant Field Values

errorPage

private java.lang.String errorPage
Constructor Detail

ErrorDispatcherServlet

public ErrorDispatcherServlet()
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Reads the "errorPage" init parameter and saves the value in an instance variable. The value must be a context-relative path to a JSP error page.

Throws:
javax.servlet.UnavailableException - if "errorPage" is not set.
javax.servlet.ServletException

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Calls doPost()

Throws:
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Sets the request attributes for the exeception and request URI and forwards to the JSP error page.

Throws:
javax.servlet.ServletException
java.io.IOException