This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JSP and the fly likes Error handling JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Error handling JSP page" Watch "Error handling JSP page" New topic

Error handling JSP page

Antonio Giovanni
Ranch Hand

Joined: Jun 27, 2005
Posts: 85
Hi all,..

Firstly i have the error page declared in web.xml

Since the error type is Exception, i assumed it handles all the exceptions.

I was testing and this is what happened:

I was going thru the web application; logged off (session is expired) and
using browser Back button i somehow came to a an URL and pressed enter and surprising this jsp page was not called when a NullPointerException happened, and in the browser i have a page showing HTTP 500 , internal Server error ???

So should i also add

to web.xml to handle this?? I will also test by adding this HTTP err code and see where it goes..

Your ideas on this; Appreciate your help;
Thanks again

PS: How do you guys do error handling and what is the best way..
[ December 16, 2005: Message edited by: Bear Bibeault ]
Madhuri Chanda

Joined: Nov 09, 2005
Posts: 10
you will have to add different <error-page> tags for different type of errors (500,404 ..etc).

and the error-page in your web.xml handles the situations when there is an exception only (from your application code).

And moreover when you said you clicked the browser's back button and then clicked enter, you got null pointer exception.. that might not be actually a null pointer exception ... since the session has expired, it could not redirect you to the next page which is not due to any exception generated.

and you can aswell display different pages for different types of errors.

Hope that helps.
I agree. Here's the link:
subject: Error handling JSP page
It's not a secret anymore!