You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/02/01 14:50:08 UTC
[tomcat] branch 10.1.x updated: Fix BZ 66441 - Make imports of static fields in JSPs visible to EL
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 01f9a9dd8d Fix BZ 66441 - Make imports of static fields in JSPs visible to EL
01f9a9dd8d is described below
commit 01f9a9dd8d6a2677c81a016dbf6e2db92bd66c71
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Feb 1 14:49:27 2023 +0000
Fix BZ 66441 - Make imports of static fields in JSPs visible to EL
https://bz.apache.org/bugzilla/show_bug.cgi?id=66441
---
.../org/apache/jasper/runtime/PageContextImpl.java | 7 +++-
.../servlet/jsp/el/TestImportELResolver.java | 39 ++++++++++++++++++++++
test/webapp/bug6nnnn/bug66441.jsp | 23 +++++++++++++
webapps/docs/changelog.xml | 4 +++
4 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/jasper/runtime/PageContextImpl.java b/java/org/apache/jasper/runtime/PageContextImpl.java
index 5d2ecbd4e5..fe88e12fa0 100644
--- a/java/org/apache/jasper/runtime/PageContextImpl.java
+++ b/java/org/apache/jasper/runtime/PageContextImpl.java
@@ -716,7 +716,12 @@ public class PageContextImpl extends PageContext {
Set<String> classImports = ((JspSourceImports) servlet).getClassImports();
if (classImports != null) {
for (String classImport : classImports) {
- ih.importClass(classImport);
+ if (classImport.startsWith("static ")) {
+ classImport = classImport.substring(7);
+ ih.importStatic(classImport);
+ } else {
+ ih.importClass(classImport);
+ }
}
}
}
diff --git a/test/jakarta/servlet/jsp/el/TestImportELResolver.java b/test/jakarta/servlet/jsp/el/TestImportELResolver.java
new file mode 100644
index 0000000000..b68529d821
--- /dev/null
+++ b/test/jakarta/servlet/jsp/el/TestImportELResolver.java
@@ -0,0 +1,39 @@
+/*
+ * 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 jakarta.servlet.jsp.el;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+public class TestImportELResolver extends TomcatBaseTest {
+
+ // https://bz.apache.org/bugzilla/show_bug.cgi?id=66441
+ @Test
+ public void testImportStaticFields() throws Exception {
+ getTomcatInstanceTestWebapp(false, true);
+
+ ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug6nnnn/bug66441.jsp");
+
+ String result = res.toString();
+
+ Assert.assertTrue(result.contains("EL - Long min value is -9223372036854775808"));
+ Assert.assertTrue(result.contains("JSP - Long min value is -9223372036854775808"));
+ }
+}
diff --git a/test/webapp/bug6nnnn/bug66441.jsp b/test/webapp/bug6nnnn/bug66441.jsp
new file mode 100644
index 0000000000..ecc45c71bc
--- /dev/null
+++ b/test/webapp/bug6nnnn/bug66441.jsp
@@ -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.
+--%>
+<%@ page import="static java.lang.Long.MIN_VALUE"%>
+<html>
+ <body>
+ <p>EL - Long min value is ${MIN_VALUE}</p>
+ <p>JSP - Long min value is <%= MIN_VALUE %></p>
+ </body>
+</html>
\ No newline at end of file
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 4e0077ae51..5b2debd984 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -127,6 +127,10 @@
Log basic information for each configured TLS certificate when Tomcat
starts. (markt)
</add>
+ <fix>
+ <bug>66441</bug>: Make imports of static fields in JSPs visible to any
+ EL expressions used on the page. (markt)
+ </fix>
<fix>
<bug>66442</bug>: When an HTTP/2 response must not include a body,
ensure that the end of stream flag is set on the headers frame and that
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org