By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,468 Members | 1,859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,468 IT Pros & Developers. It's quick & easy.

response.setStatus & response.sendRedirect

P: n/a
I have a situation when I need to set the response status code to a
non 200 and then serve up a generic error page (html page not a jsp).

I can successfully call response.setStatus(
response.SC_INTERNAL_ERROR) and then forward to the page using

This displays the page I want and returns a 500 status code.
response.setStatus( response.SC_INTERNAL_SERVER_ERROR )
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher( aPage );
dispatcher.forward( request, response );
This displays the page I want, but returns a 200 status code
(presumably because the page that was redirected to was served
response.setStatus( response.SC_INTERNAL_SERVER_ERROR );
response.sendRedirect( aPage );
I cannot use the forward logic in my scenario because I want to stop
any further processing of internally included JSP's or servlets.
Anyone know how to set the status code of the HTML page that I
redirected to?
Thanks in advance,
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.