The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Handling multiple error code through one entry in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Handling multiple error code through one entry in web.xml" Watch "Handling multiple error code through one entry in web.xml" New topic
Author

Handling multiple error code through one entry in web.xml

Kumari Priyanka
Greenhorn

Joined: Dec 29, 2008
Posts: 7
Hi All,

Is it possible to handle multiple error codes using only one entry in the web.xml??

I mean for example if I have to handle 404 error code, I will make the following entry in web.xml :-

<error-page>
<error-code>404</error-code>
<location>/pageNotfound</location>
</error-page>

But now I want to handle all the error codes of 500 range like 500, 501, 502.. etc....

Is it possible to write a generalize error code thing and handle all the error codes frrom say 500 - 600, and redirect it to same error page?

Thanks in advance for giving some pointer on this.

Thanks
Priyanka
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1351
If I were at your place, I would put following entries in web.xml and forget them all.



But thing is I don't know how to produce 500,501 errors to test scenarios.

Do you know how to produce them?


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Kumari Priyanka
Greenhorn

Joined: Dec 29, 2008
Posts: 7
Thanks Akhilesh.... but that entry will only take care for error code 500 not the all 500 series error code.
and yeah you can set the error code in response programatically.... response.setStatusCode()
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1351
Thanks. See if this works.



Do keep the entry for 404 also.
 
IntelliJ Java IDE
 
subject: Handling multiple error code through one entry in web.xml
 
Threads others viewed
Handle all error codes other than one
tomcat 5 and error page
Sample web.xml.. may be useful for SCWCD Ranchers
Error Page
tomcat 5 and error page
IntelliJ Java IDE