This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP and custom Exception class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP and custom Exception class" Watch "JSP and custom Exception class" New topic
Author

JSP and custom Exception class

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
I am trying to generate a custom error and then send it to the Error.jsp page but I am having a problem. Here is what I have done:
I have created a very basic exception class.
package lampoonslodge;
public class SessionException extends Exception {
public SessionException(){
super("Session or page has expired");
}
}
/************************************************************/
I then have a jsp with the following line of code-
if(true)
throw (new SessionException());
/**************************************************************/
In my web.xml file I have the following syntax
<error-page>
<exception-type>lampoonslodge.SessionException</exception-type>
<location>/Error.jsp</location>
</error-page>
/**************************************************************/
So why does it not work
When the code executes int the jsp it does display my error message but under a 500 error heading. It does not go to error page.
Could someone please help me with this one.
Thank you ver much david
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 631
David,
I m not sure abt
<error-page>
<exception-type>lampoonslodge.SessionException</exception-type>
<location>/Error.jsp</location>
</error-page>
but I think jsp provides better and easy option for above lines as
<%@ page errorPage="Error.jsp" %> this will appear in ur main jsp
and
<%@ page isErrorPage=true %> in Error.jsp
Hope this solves ur problem
Praful


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSP and custom Exception class