• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Redirect internal server error to custom JSP

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have J2EE application(I am using Struts2 / EJB3.0). I have used the below code in web.xml to catch the 500 error,


If 500 error is caused by my JSP (meaning i missed some tags/ some error in jsp) i am redirected to my custom error page. But if there is some error in my action / network time out / null pointer exception i am not redirected to my custom error page instead i get HTTP INTERNAL SERVER ERROR.

Please let me know if i have to any other configuration in web.xml for me to get redirected to my custom error page.

Thanks in advance.
 
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For handling exceptions, you should use the <exception-type> within the <error-page> element.
 
Manigandan Velraj
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply,

Can you please post a sample web.xml containing the exception handling.

Thanks.
 
Devaka Cooray
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simply specify the exception class name for the <exception-type> element.

For handling all of the exceptions, use java.lang.Throwable as the exception type.
 
Manigandan Velraj
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for the info.. This was helpful. If i use java.lang.Throwable will i be able to catch the network timeout / response time outs.

Also can you please let me know the advantage of using java.lang.Throwable instead of java.lang.Exception.

Thanks in advance.
 
Devaka Cooray
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use java.lang.Throwable instead of java.lang.Exception, it can handle all of the exceptions, and 5xx errors (but not 4xx errors). For handling 4xx errors, you should use separate error-page declaration with proper error-code specifications.

Devaka
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic