diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java index 4eb9deb893f1..aea2b7fbaea6 100644 --- a/java/org/apache/jasper/compiler/Generator.java +++ b/java/org/apache/jasper/compiler/Generator.java @@ -1082,7 +1082,7 @@ public void visit(Node.IncludeAction n) throws JasperException { } if (n.getBody() != null) { - generateIncludeWithParameters(n, page, isFlush, pageParam); + generateIncludeWithParameters(n, isFlush, pageParam); } else { generateInclude(n, page, isFlush, pageParam); } @@ -1097,8 +1097,8 @@ private void generateInclude(Node.IncludeAction n, Node.JspAttribute page, boole out.println(", out, " + isFlush + ");"); } - private void generateIncludeWithParameters(Node.IncludeAction n, Node.JspAttribute page, boolean isFlush, - String pageParam) throws JasperException { + private void generateIncludeWithParameters(Node.IncludeAction n, boolean isFlush, String pageParam) + throws JasperException { // jsp:include contains jsp:param - reuse some calculations String temporaryVariableName = n.getRoot().nextTemporaryVariableName(); String urlVariableName = temporaryVariableName + "_url"; @@ -1108,7 +1108,8 @@ private void generateIncludeWithParameters(Node.IncludeAction n, Node.JspAttribu out.printin("String " + requestEncodingVariableName + " = " + REQUEST_CHARACTER_ENCODING_TEXT + ";"); out.println(); out.printin("org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, " + urlVariableName); - printParams(n, urlVariableName, page.isLiteral(), requestEncodingVariableName); + // literal is hard-coded to false for this call since it always uses a variable + printParams(n, urlVariableName, false, requestEncodingVariableName); out.println(", out, " + isFlush + ");"); } diff --git a/test/org/apache/jasper/compiler/TestGenerator.java b/test/org/apache/jasper/compiler/TestGenerator.java index 892e398660b3..70e8e18ff3b9 100644 --- a/test/org/apache/jasper/compiler/TestGenerator.java +++ b/test/org/apache/jasper/compiler/TestGenerator.java @@ -971,6 +971,37 @@ public void testBug65390() throws Exception { Assert.assertEquals(body.toString(), HttpServletResponse.SC_OK, rc); } + @Test + public void testBug69508() throws Exception { + getTomcatInstanceTestWebapp(false, true); + + ByteChunk body = new ByteChunk(); + int rc = getUrl("http://localhost:" + getPort() + "/test/bug6nnnn/bug69508.jsp?init=InitCommand", body, null); + + String text = body.toString(); + Assert.assertEquals(text, HttpServletResponse.SC_OK, rc); + // include page URL with param cmd + Assert.assertTrue(text, text.contains("
cmd - someCommand
")); + Assert.assertTrue(text, text.contains("param1 - value1
")); + Assert.assertTrue(text, text.contains("cmd - someCommandAbs
")); + Assert.assertTrue(text, text.contains("param1 - value1Abs
")); + // include page URL without param + Assert.assertTrue(text, text.contains("param2 - value2
")); + Assert.assertTrue(text, text.contains("param2 - value2Abs
")); + + Assert.assertTrue(text, text.contains("param3 - InitCommand
")); + Assert.assertTrue(text, text.contains("param3 - InitCommandAbs
")); + + Assert.assertTrue(text, text.contains("param4 - value4
")); + Assert.assertTrue(text, text.contains("param4 - value4Abs
")); + + Assert.assertTrue(text, text.contains("param5 - InitCommand
")); + Assert.assertTrue(text, text.contains("param5 - InitCommandAbs
")); + + Assert.assertTrue(text, text.contains("param6 - value6
")); + Assert.assertTrue(text, text.contains("param6 - value6Abs
")); + } + @Test public void testTagReleaseWithPooling() throws Exception { doTestTagRelease(true); diff --git a/test/webapp/bug6nnnn/bug69508.jsp b/test/webapp/bug6nnnn/bug69508.jsp new file mode 100644 index 000000000000..2839a850eae4 --- /dev/null +++ b/test/webapp/bug6nnnn/bug69508.jsp @@ -0,0 +1,64 @@ +<%-- + 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. +--%> + +