Author: markt
Date: Sat Aug 11 09:43:19 2012
New Revision: 1371896
URL: http://svn.apache.org/viewvc?rev=1371896&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53545
Ensure buffered data is cleared when using a jsp:forward action to a static
resource inside classic a custom tag
Added:
tomcat/trunk/test/org/apache/jasper/runtime/
tomcat/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java
tomcat/trunk/test/org/apache/tomcat/unittest/tags/
tomcat/trunk/test/org/apache/tomcat/unittest/tags/Bug53545.java
tomcat/trunk/test/webapp-3.0/WEB-INF/bug53545.tld
tomcat/trunk/test/webapp-3.0/bug53545.html
tomcat/trunk/test/webapp-3.0/bug53545.jsp
Modified:
tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java
Modified: tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java?rev=1371896&r1=1371895&r2=1371896&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java (original)
+++ tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java Sat Aug 11
09:43:19 2012
@@ -715,6 +715,7 @@ public class PageContextImpl extends Pag
// JSP.4.5 If the buffer was flushed, throw IllegalStateException
try {
out.clear();
+ baseOut.clear();
} catch (IOException ex) {
IllegalStateException ise = new IllegalStateException(Localizer
.getMessage("jsp.error.attempt_to_clear_flushed_buffer"));
Added: tomcat/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java?rev=1371896&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java (added)
+++ tomcat/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java Sat
Aug 11 09:43:19 2012
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jasper.runtime;
+
+import java.io.File;
+
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import org.apache.catalina.startup.Tomcat;
+import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+public class TestPageContextImpl extends TomcatBaseTest {
+
+ @Test
+ public void testDoForward() throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ File appDir = new File("test/webapp-3.0");
+ tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+
+ tomcat.start();
+
+ ByteChunk res = new ByteChunk();
+
+ int rc = getUrl("http://localhost:" + getPort() +
+ "/test/bug53545.jsp", res, null);
+
+ Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+
+ String body = res.toString();
+ Assert.assertTrue(body.contains("OK"));
+ Assert.assertFalse(body.contains("FAIL"));
+ }
+}
Added: tomcat/trunk/test/org/apache/tomcat/unittest/tags/Bug53545.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/unittest/tags/Bug53545.java?rev=1371896&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/unittest/tags/Bug53545.java (added)
+++ tomcat/trunk/test/org/apache/tomcat/unittest/tags/Bug53545.java Sat Aug 11
09:43:19 2012
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.unittest.tags;
+
+import javax.servlet.jsp.tagext.BodyTagSupport;
+
+public class Bug53545 extends BodyTagSupport {
+ private static final long serialVersionUID = 1L;
+}
Added: tomcat/trunk/test/webapp-3.0/WEB-INF/bug53545.tld
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/WEB-INF/bug53545.tld?rev=1371896&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/WEB-INF/bug53545.tld (added)
+++ tomcat/trunk/test/webapp-3.0/WEB-INF/bug53545.tld Sat Aug 11 09:43:19 2012
@@ -0,0 +1,12 @@
+<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ version="2.0">
+ <tlib-version>1.0</tlib-version>
+ <short-name>bug53545</short-name>
+ <tag>
+ <name>test</name>
+ <tag-class>org.apache.tomcat.unittest.tags.Bug53545</tag-class>
+ <body-content>scriptless</body-content>
+ </tag>
+</taglib>
\ No newline at end of file
Added: tomcat/trunk/test/webapp-3.0/bug53545.html
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug53545.html?rev=1371896&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug53545.html (added)
+++ tomcat/trunk/test/webapp-3.0/bug53545.html Sat Aug 11 09:43:19 2012
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <p>OK</p>
+ </body>
+</html>
\ No newline at end of file
Added: tomcat/trunk/test/webapp-3.0/bug53545.jsp
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug53545.jsp?rev=1371896&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug53545.jsp (added)
+++ tomcat/trunk/test/webapp-3.0/bug53545.jsp Sat Aug 11 09:43:19 2012
@@ -0,0 +1,34 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<%@ taglib prefix="bug53545" uri="/WEB-INF/bug53545.tld" %>
+<html>
+ <body>
+ <p>FAIL</p>
+ <bug53545:test>
+ <p>FAIL</p>
+ <bug53545:test>
+ <p>FAIL</p>
+ <jsp:forward page="bug53545.html"/>
+ <p>FAIL</p>
+ </bug53545:test>
+ <p>FAIL</p>
+ </bug53545:test>
+ <p>FAIL</p>
+ </body>
+</html>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]