tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32688] New: - Setting content length to 0 stops sendRedirect
Date Tue, 14 Dec 2004 09:59:13 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32688>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32688

           Summary: Setting content length to 0 stops sendRedirect
           Product: Tomcat 5
           Version: 5.0.30
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Connector:Coyote
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: etouchard@infovista.com


Here is my example:
Test.jsp
<%@page language="java"  contentType="text/html;charset=utf-8" 
pageEncoding="utf-8"  %><%response.setContentLength(0);response.sendRedirect
("http://www.apache.org");%>

(all on the same line)

by calling this jsp i've got the following answer
HTTP Status 500 - 

--------------------------------------------------------------------------------

type Exception report

message 

description The server encountered an internal error () that prevented it from 
fulfilling this request.

exception 

java.lang.IllegalStateException
	org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect
(CoyoteResponseFacade.java:352)
	org.apache.jsp.Test_jsp._jspService(Test_jsp.java:46)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

According to the specification:
setContentLength(int)
public void setContentLength(int len)
Sets the length of the content body in the response In HTTP servlets, this
method sets the HTTP Content-Length header.
Parameters:
len - an integer specifying the length of the content being returned to the
client; sets the Content-Length header

sendRedirect(String)
public void sendRedirect(java.lang.String location)
throws IOException
Sends a temporary redirect response to the client using the specified redirect
location URL. This method can accept relative URLs; the servlet container
must convert the relative URL to an absolute URL before sending the
response to the client. If the location is relative without a leading ’/’ the 
container
interprets it as relative to the current request URI. If the location is 
relative
with a leading ’/’ the container interprets it as relative to the servlet
container root.
If the response has already been committed, this method throws an Illegal-
StateException. After using this method, the response should be considered
to be committed and should not be written to.
Parameters:
location - the redirect location URL
Throws:
IOException - If an input or output exception occurs
IllegalStateException - If the response was committed or if a partial URL
is given and cannot be converted into a valid URL

SRV.5.5 Closure of Response Object
When a response is closed, the container must immediately flush all remaining
content in the response buffer to the client. The following events indicate 
that the
servlet has satisfied the request and that the response object is to be closed:
• The termination of the service method of the servlet.
• The amount of content specified in the setContentLength method of the response
has been written to the response.
• The sendError method is called.
• The sendRedirect method is called.

As I am not writting in the content (I've check in the jsp compilation file) 
but just put some http header this should work.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message