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 2014/11/01 22:44:22 UTC
svn commit: r1636063 - in /tomcat/trunk:
java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
test/org/apache/el/TestELInJsp.java test/webapp/bug5nnnn/bug57141.jsp
webapps/docs/changelog.xml
Author: markt
Date: Sat Nov 1 21:44:22 2014
New Revision: 1636063
URL: http://svn.apache.org/r1636063
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57141
Enable EL in JSPs to refer to static fields of imported classes including the standard java.lang.* imports.
Added:
tomcat/trunk/test/webapp/bug5nnnn/bug57141.jsp (with props)
Modified:
tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
tomcat/trunk/test/org/apache/el/TestELInJsp.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java?rev=1636063&r1=1636062&r2=1636063&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java Sat Nov 1 21:44:22 2014
@@ -22,8 +22,10 @@ import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
+import javax.el.ELClass;
import javax.el.ELContext;
import javax.el.ELResolver;
+import javax.el.ImportHandler;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.PageContext;
@@ -43,17 +45,30 @@ public class ScopedAttributeELResolver e
throw new NullPointerException();
}
+ Object result = null;
+
if (base == null) {
context.setPropertyResolved(base, property);
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context
.getContext(JspContext.class);
- return page.findAttribute(key);
+ result = page.findAttribute(key);
+
+ if (result == null) {
+ // This might be the name of an import class
+ ImportHandler importHandler = context.getImportHandler();
+ if (importHandler != null) {
+ Class<?> clazz = importHandler.resolveClass(key);
+ if (clazz != null) {
+ result = new ELClass(clazz);
+ }
+ }
+ }
}
}
- return null;
+ return result;
}
@Override
Modified: tomcat/trunk/test/org/apache/el/TestELInJsp.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestELInJsp.java?rev=1636063&r1=1636062&r2=1636063&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/TestELInJsp.java (original)
+++ tomcat/trunk/test/org/apache/el/TestELInJsp.java Sat Nov 1 21:44:22 2014
@@ -385,6 +385,22 @@ public class TestELInJsp extends TomcatB
}
+ /*
+ * java.lang should be imported by default
+ */
+ @Test
+ public void testBug57141() throws Exception {
+ getTomcatInstanceTestWebapp(false, true);
+
+ ByteChunk res = getUrl("http://localhost:" + getPort() +
+ "/test/bug5nnnn/bug57141.jsp");
+
+ String result = res.toString();
+ assertEcho(result, "00-true");
+ assertEcho(result, "01-false");
+ }
+
+
// Assertion for text contained with <p></p>, e.g. printed by tags:echo
private static void assertEcho(String result, String expected) {
assertTrue(result, result.indexOf("<p>" + expected + "</p>") > 0);
Added: tomcat/trunk/test/webapp/bug5nnnn/bug57141.jsp
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug57141.jsp?rev=1636063&view=auto
==============================================================================
--- tomcat/trunk/test/webapp/bug5nnnn/bug57141.jsp (added)
+++ tomcat/trunk/test/webapp/bug5nnnn/bug57141.jsp Sat Nov 1 21:44:22 2014
@@ -0,0 +1,22 @@
+<%--
+ 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.
+--%>
+<html>
+ <body>
+ <p>00-${Boolean.TRUE}</p>
+ <p>01-${Boolean.FALSE}</p>
+ </body>
+</html>
\ No newline at end of file
Propchange: tomcat/trunk/test/webapp/bug5nnnn/bug57141.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1636063&r1=1636062&r2=1636063&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Sat Nov 1 21:44:22 2014
@@ -297,6 +297,11 @@
represent exanded JARs files that have been added to the web application
class loader's class path. (markt)
</fix>
+ <fix>
+ <bug>57141</bug>: Enable EL in JSPs to refer to static fields of
+ imported classes including the standard <code>java.lang.*</code>
+ imports. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Cluster">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org