aspose file tools*
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
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: 3216
    
  49

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


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
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: 3216
    
  49

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.
 
 
subject: Replicating HTTP errors