0

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.

Nick Donovan
  • 37
  • 1
  • 5
  • Pass all the request from filter and handle any exception caught at server side. – Braj Jun 08 '14 at 15:21
  • possible duplicate of [How to show user-friendly error page instead of tomcat log with stack trace in browser when runtime exception is thrown?](http://stackoverflow.com/questions/2748220/how-to-show-user-friendly-error-page-instead-of-tomcat-log-with-stack-trace-in-b) – Raedwald Jun 08 '14 at 16:49
  • Thank you, the answer of user1428716 works fine. – Nick Donovan Jun 08 '14 at 16:59

1 Answers1

1

Define in your web.xml

<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.jsp</location>
</error-page>
user1428716
  • 2,078
  • 2
  • 18
  • 37
  • Thank youi.I didn't have any web.xml in my project. I am using tomcat apache. Anyway I created a new web.xml in Webcontent/Web-inf, but still the exctepions aren't handled – Nick Donovan Jun 08 '14 at 16:33
  • thank you very much, it worked, I just needed to restart the application – Nick Donovan Jun 08 '14 at 16:58