To call Jsp Error page from servlet you need to do a trick. First of all we should know If the source of the exception was a JSP page, the Web container also stores the exception as a request attribute called "javax.servlet.jsp.jspException"
So if you want from Servlet to JSP-Error-Page then you have to set the exception in the same way as the Web Container does ie in the catch block you set : request.setAttribute("javax.servlet.jsp.jspException"); then use RequestDispatcher to forwrd to your error page
why calling error page. It would be called whenever error occurs, just make erorpage entry in your web.xml
Joined: Nov 22, 2004
As my understanding about this is,
If you use <error-page> element of web.xml to divert to error pages, all the jsp/servlets that gets that exception will be directed to the same error page.
If you do it the way as mentioned in the above Post(by using RequestDispatcher), you can have corresponding error page for some jsp/servlet. (for jsp you could use page directive attribute errorPage=" "). So that these error pages to which request get diverted show more specific information.
I think that is what sitaram irrinki wanted. Please correct me if i am wrong.
Joined: Aug 15, 2004
Originally posted by Nikhil Menon: So that these error pages to which request get diverted show more specific information.
Well, i think we can just show more specific message there on general error page.