> Delivered-To: [EMAIL PROTECTED]
> Date: Mon, 27 Aug 2001 16:03:34 +0700
> From: Dinesh Somasundram <[EMAIL PROTECTED]>
> Subject: forward / sendRedirect
> To: [EMAIL PROTECTED]
>
> Hi All,
>
> I have a page. In the middle of the page, if a certain condition is true, I
> want to go to a different page. If I use response.sendRedirect(), I keep
> getting "Response has already been committed". If I use jsp:forward I keep
> getting "Cannot forward as OutputStream or Writer has already been obtained"
>
> Any ideas.... or I just cannot forward to another page from within the
> middle of my JSP. Please kindly advice.
Since the HTTP redirect header is, well, a header, once the headers have been
written (i.e. after the HTML has already been sent) you can no longer use
redirection. Similarly, the jsp:forward mechanism is designed to transfer the
processing of a JSP page to another before *any* data (including headers) are
sent to the client.
The only way to do "redirect" a user after the data has been written would be to
use client-side scripting such as JavaScript.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets