Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help: response.sendRedirect(url) and default page?

843842Feb 5 2009 — edited Feb 6 2009
I have the following code:
// part of the doPost(...) section of a servlet
       response.sendRedirect("someurl");
	RequestDispatcher view = servletContext.getRequestDispatcher("/someFile.jsp");
	view.forward(request, response);
I would like the browser to redirect, but if for some reason the browser doesn't redirect should display a page indicating where the user should go. However, trying the above code does not work and gives me an exception:

java.lang.IllegalStateException: Cannot forward after response has been committed

1. Any idea's on how I can achieve this?

2. Is there any chance at all that the redirect might not happen on the browser end?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2009
Added on Feb 5 2009
8 comments
566 views