This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
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: 1527
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: 1527
Thanks. See if this works.



Do keep the entry for 404 also.
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
for server specific exceptions we can keep



for page not found errors we must write


Thanks
Vipul Kumar


Thanks
Vipul Kumar
 
GeeCON Prague 2014
 
subject: Handling multiple error code through one entry in web.xml