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=31741>. 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=31741 servlet request forward to jsp with <jsp:include> tag can cause extra request to be submitted Summary: servlet request forward to jsp with <jsp:include> tag can cause extra request to be submitted Product: Tomcat 4 Version: 4.1.30 Platform: PC OS/Version: Solaris Status: NEW Severity: Major Priority: Other Component: Jasper 2 AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] We seem to have found a case where 2 clicks from a browser cause 3 requests to be processed by the servlet. The steps to reproduce are: - Set up the servlet and JSP files as below - Start with the HTML file - Click the Submit button once, wait 1 second (first request will not be complete) and then click it again - You'll see 2 requests (correct) in the Apache log and 3 requests (incorrect) processed in catalina.out We found this while doing some debugging on our application. This was done on a Solaris Intel machine running Apache 2.0.48 and the 2.0.4 JK connectors using the CoyoteConnector config in server.xml. A couple of things that seem to be necessary for this: - The flush must be set to true in the jsp:include directive - There must be some kind of output in the including page before the include directive Log I captured -> request 3 seems to be spawned after request 1 completes --------------- WebappClassLoader: Resource '/WEB- INF/classes/ServletJSPForwardAndIncludeTest.class' was modified; Date is now: Fri Oct 15 21:33:15 EDT 2004 Was: Fri Oct 15 20:42:29 EDT 2004 Request: [EMAIL PROTECTED] reqNum=1: Start Request: [EMAIL PROTECTED] reqNum=1: Sleep Request: [EMAIL PROTECTED] reqNum=2: Start Request: [EMAIL PROTECTED] reqNum=2: Forward Request: [EMAIL PROTECTED] reqNum=2: Finish Request: [EMAIL PROTECTED] reqNum=1: Forward Request: [EMAIL PROTECTED] reqNum=1: Finish Request: [EMAIL PROTECTED] reqNum=3: Start Request: [EMAIL PROTECTED] reqNum=3: Sleep Request: [EMAIL PROTECTED] reqNum=3: Forward Request: [EMAIL PROTECTED] reqNum=3: Finish Oct 15, 2004 9:33:53 PM org.apache.jk.server.JkCoyoteHandler action SEVERE: Error in action code java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:457) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:654) at org.apache.jk.server.JkCoyoteHandler.action(JkCoyoteHandler.java:472) at org.apache.coyote.Response.action(Response.java:226) at org.apache.coyote.Response.finish(Response.java:348) at org.apache.coyote.tomcat4.OutputBuffer.close(OutputBuffer.java:324) at org.apache.coyote.tomcat4.CoyoteResponse.finishResponse (CoyoteResponse.java:486) at org.apache.coyote.tomcat4.CoyoteAdapter.service (CoyoteAdapter.java:200) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:324) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:395) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:673) at org.apache.jk.common.ChannelSocket.processConnection (ChannelSocket.java:615) at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:786) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run (ThreadPool.java:683) at java.lang.Thread.run(Thread.java:534) Oct 15, 2004 9:33:53 PM org.apache.jk.server.JkCoyoteHandler action SEVERE: Error in action code java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:457) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:654) at org.apache.jk.server.JkCoyoteHandler.action(JkCoyoteHandler.java:472) at org.apache.coyote.Response.action(Response.java:226) at org.apache.coyote.Response.finish(Response.java:348) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:329) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:395) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:673) at org.apache.jk.common.ChannelSocket.processConnection (ChannelSocket.java:615) at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:786) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run (ThreadPool.java:683) at java.lang.Thread.run(Thread.java:534) ServletJSPForwardAndIncludeTest --------------- /* * Created on Oct 15, 2004 */ import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** * @author rbaily */ public class ServletJSPForwardAndIncludeTest extends HttpServlet { static int requestNum = 0; public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { doPost(req, res); } public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { requestNum += 1; int myReq = requestNum; String id = "Request: " + req.toString() + " reqNum=" + myReq + ": "; System.out.println( id + "Start" ); if (myReq % 2 == 1) { System.out.println( id + "Sleep" ); try { Thread.sleep( 5000 ); } catch (InterruptedException e) { System.out.println( id + "Interrupted" ); } } String page = "/includes_file.jsp"; RequestDispatcher rd = getServletContext().getRequestDispatcher (page); System.out.println( id + "Forward" ); rd.forward( req, res ); System.out.println( id + "Finish" ); } } includes_file.jsp --------------- There has to be text above the included file <jsp:include page="included_file.jsp" flush="true" /> This is the file that includes another one included_file.jsp --------------- This is the included file include_test.html --------------- <form action="servlet/ServletJSPForwardAndIncludeTest"> <input type=submit value="Submit"> </form> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]