Re: Redirecting the browser to another page

Eric Noriega <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Organization The George Washington University, Department of Computer Science
Message-ID <[email protected]>
    How do you close the output stream before redirecting?  The whole
point is that the redirect has to happen before the commit.   Otherwise
the response headers have been sent, and so the redirect response code
cannot be sent.

    Just put the tag at the start of the jsp file.

<%@page ...
%><%@ taglib uri="http://jakarta.apache.org/taglibs/response-1.0"
prefix="response"
%><response:sendRedirect><response:encodeRedirectUrl>"http://somepage.jsp"</response:encodeRedire
ctUrl></response:sendRedirect>

etc . .




V. Jagadesh Lee wrote:

>Usually before redirecting response or before forwarding request it is
>best not open the output stream. If the output stream is committed then
>you should flush or close the output stream before redirecting. Some
>times the errors associated with redirecting and forwarding is due to
>the web container implementation. In such case you should contact the
>vendor.
>
>Lee
>
>-----Original Message-----
>From: A mailing list for discussion about Sun Microsystem's Java Servlet
>API Technology. [mailto:[email protected]] On Behalf Of Asad
>Habib
>Sent: Thursday, June 19, 2003 8:33 PM
>To: [email protected]
>Subject: Redirecting the browser to another page
>
>Does anyone know how to do this successfully? I am using the "response"
>Jakarta Taglib but I keep getting the following error:
>
>javax.servlet.ServletException: Response sendRedirect tag could not
>return the redirect: Response has already been committed
>
>I am using the following code:
>
><%@ taglib uri="http://jakarta.apache.org/taglibs/response-1.0"
>prefix="response" %>
>
><response:sendRedirect>
>
><response:encodeRedirectUrl>"http://somepage.jsp"</response:encodeRedire
>ctUrl>
></response:sendRedirect>
>
>I don't quite understand how the server has committed a request to the
>client and if it has, how can I uncommit that request so that the client
>can be redirected successfully?
>
>Any help would be greatly appeciated. Thanks.
>
>-Asad
>
>________________________________________________________________________
>___
>To unsubscribe, send email to [email protected] and include in the
>body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>___________________________________________________________________________
>To unsubscribe, send email to [email protected] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
>

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.