In the case of error, the servlet needs to save session data along with the exception details in a cookie.
Create a new ServletException and throw this exception to the main thread.
The servlet should raise JspException. Original exception can be saved within JspException.
The servlet forwards the request to the specific error page with the exception passed
as the "javax.servlet.jsp.jspException" attribute.
The error page can be specified with the error-page tag in the descriptor file.
No special coding requires.
If an error happens in the servlet, the main thread will automatically handle the exception.
|