Nick Donovan
Nick Donovan

Reputation: 37

How to handle all exceptions in a web java project

I am doing an web java project about an hotel reservation. I am using, sql, hibernate, java server pages.

I want to know how can I redirect an incoming exception to an error.jsp file . There are a lot of java code , and a lot of jsp file. So I want to rederict every exception that I haven't handle to an error page, is there any way to do it ? An exception can come from everywhere and I can't know and handle them all ( for example an user can write to much data in an textfield, and it will generate me an sql exception for data to long)

Thank you, sorry for my english.

Upvotes: 0

Views: 476

Answers (1)

user1428716
user1428716

Reputation: 2136

Define in your web.xml

<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.jsp</location>
</error-page>

Upvotes: 1

Related Questions