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=38047>.
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=38047

           Summary: Request.getReader() broken for tomcat + Apache2.2.0/mod
                    jk_1.2.15
           Product: Tomcat 5
           Version: 5.5.14
          Platform: All
               URL: http://localhost/hello.jsp
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Servlet & JSP API
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


Tomcat 5.5.14 running with the latest mod_jk (1.2.15) + Apache 2.2.0 causes 
bizarre 
and buggy behavior with request.getReader().

This does NOT happen if the same jsp is accessed directly via localhost:8080

Consider the following JSP (called hello.jsp):

---------------------------start -----------------------
hello world
<% 
out.println("2+2=" + (2+2)); 
out.print(request.getMethod());
out.print(" ");
out.print(request.getRequestURI());
String s = request.getQueryString();
if (s != null) {
        out.print("?");
        out.println(s);
        }
out.print("<br>PATH_INFO=" + request.getPathInfo());
out.print("<br>PATH_TRANSLATED=" + request.getPathInfo());
out.print("<br>SERVLET_PATH=" + request.getServletPath());
out.print("<br>QUERY_STRING=" + request.getQueryString());
%>

<h2>POST PARAMS</h2>
<%
java.io.Reader in = request.getReader();
int c = -1;
while ( (c = in.read()) != -1) {
        out.print((char)c);
        System.out.print((char)c);
        }
%>

-------------------------------- end ------------------------------

This results in the following time out and stack trace. This is because the 
reader returned
by request.getReader() DOES NOT return -1

-------------------------- start 
-------------------------------------------------
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from 
fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /hello.jsp:22

19: <%
20: java.io.Reader in = request.getReader();
21: int c = -1;
22: while ( (c = in.read()) != -1) {
23:     out.print((char)c);
24:     System.out.print((char)c);
25:     }


Stacktrace:
        
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
        
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:381)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause

java.net.SocketTimeoutException: Read timed out
        java.net.SocketInputStream.socketRead0(Native Method)
        java.net.SocketInputStream.read(SocketInputStream.java:129)
        java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
        java.io.BufferedInputStream.read(BufferedInputStream.java:313)
        org.apache.jk.common.ChannelSocket.read(ChannelSocket.java:607)
        org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:545)
        org.apache.jk.common.JkInputStream.receive(JkInputStream.java:184)
        org.apache.jk.common.JkInputStream.doRead(JkInputStream.java:163)
        org.apache.coyote.Request.doRead(Request.java:423)
        
org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:283)
        
org.apache.catalina.connector.InputBuffer.realReadChars(InputBuffer.java:329)
        org.apache.tomcat.util.buf.CharChunk.substract(CharChunk.java:382)
        org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:351)
        org.apache.catalina.connector.CoyoteReader.read(CoyoteReader.java:92)
        org.apache.jsp.hello_jsp._jspService(org.apache.jsp.hello_jsp:64)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
---------------------------------- end -------------------------

Here is the mod_jk.conf file:

LoadModule jk_module modules/mod_jk.so
JkWorkersFile           /usr/local/tomcat/conf/worker.properties
JkLogFile                       /usr/local/tomcat/logs/mod_jk.log
JkLogLevel                      info    
JkLogStampFormat        "[%a %b %d %H:%M:%S %Y] "
JkRequestLogFormat  "%s %w %V %T %s"
JkOptions     +ForwardURICompat
JkOptions     +ForwardDirectories
JkMount /*.jsp w1
JkMount /*/servlet/ w1
JkMount /*.page w1

And here is worker.properties:
worker.list=w1,jkstatus
worker.maintain=120
worker.w1.type=ajp13
worker.w1.host=localhost
worker.w1.port=8009
worker.w1.socket_timeout=120
worker.w1.recycle_timeout=500
worker.jkstatus.type=status

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to