• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Exception redirect to page

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sometimes I have Servlets in my Tomcat 4.1.27 container that display information and there might be times when an Exception happens. I like to have a redirect to show a user friendly error page. The below is how I have been doing it and was wondering if this is the proper way to do it where the error message goes to the Tomcat log file and the page redirects.
 
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not the proper way. Rather you should not catch the exception at all. Declare your error page(es) in the web.xml. The Servlet Specificatin spells all of this out in the error handling section.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the web.xml


someErrorfullPage.jsp




Thanks,
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cmbhatt,

In the error page you will not have "code that may cause the exception" rather you may have code that generate useful message to the user about what the problem was.

regards,

Majid
 
Greenhorn
Posts: 10
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

U said <error-page> in web.xml
my Quest. is where we write <error-page> tag i.e.in servlet tag or
servlet-mapping tag.


Thanks in Advance
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does this mean if it generates an error/exception in the action/service class it will log the error and redirect to the error.jsp?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Vyas",
after multiple requests to correct your display name, I am now disabling your account.

If you would like to participate in this conversation, please do so with an account with a valid display name.

Dave
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kishore there is no error tag in servlet or servlet-mapping tag. There is a separate tag called

<error-page> and the attributes of these are

<error-code>
<exception-type>
<location>
 
reply
    Bookmark Topic Watch Topic
  • New Topic