This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Replicating HTTP errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Replicating HTTP errors" Watch "Replicating HTTP errors" New topic
Author

Replicating HTTP errors

Ramin Esfandiari
Greenhorn

Joined: Mar 15, 2013
Posts: 16

Hi

I have set up my custom error pages in Tomcat 7 (running from eclipse). For testing that they work I can simply misspell a url and get my custom page 404 error, however I am not sure how I can replicate the following errors.

400, 401, 403, 500 and 503.

Any advice would be greatly appreciated.

Thanks


Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3018
    
  35

Assuming you have access to the codebase, response.sendError(-) is all what you need.


Founder of ExamLab and Systemup
See how I can help you to become an awesome programmer
Ramin Esfandiari
Greenhorn

Joined: Mar 15, 2013
Posts: 16

Thanks for the reply.

Apologies, but I am a bit confused. I am interested in the response I get from my server. I need something that I can use in the browser to say cause a page 500 error so I can see how my custom error 500 page looks. Can I do this with response.sendError(-)?

Thanks
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3018
    
  35

You can't simply use your browser to trigger a server error (especially in 5xx series), unless you make your web app do that. Since you seem to have access to your codebase, you can make a test servlet that calls response.sendError(500); in its doGet(-) method, which will trigger a 500 error when that servlet is 'called' from your browser. You can see how your custom error pages look like with that.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Replicating HTTP errors
 
Similar Threads
Return types from execute() method in struts2 action
Throw custom exception in jsp page..
How to replicate page 404 in Tomcat 7.0 (running in Eclipse)
error messages
Error Page Not Found