Author: remy.maucherat(a)jboss.com
Date: 2009-07-07 12:54:44 -0400 (Tue, 07 Jul 2009)
New Revision: 1129
Modified:
trunk/java/org/apache/jasper/compiler/Generator.java
trunk/java/org/apache/jasper/compiler/PageInfo.java
trunk/webapps/docs/changelog.xml
Log:
- Port getProperty fix.
Modified: trunk/java/org/apache/jasper/compiler/Generator.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Generator.java 2009-06-24 07:22:30 UTC (rev
1128)
+++ trunk/java/org/apache/jasper/compiler/Generator.java 2009-07-07 16:54:44 UTC (rev
1129)
@@ -31,6 +31,7 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.Vector;
import javax.el.MethodExpression;
@@ -87,6 +88,8 @@
private BeanRepository beanInfo;
+ private Set<String> varInfoNames;
+
private JspCompilationContext ctxt;
private boolean isPoolingEnabled;
@@ -1124,18 +1127,26 @@
+ ")_jspx_page_context.findAttribute("
+ "\""
+ name + "\"))." + methodName +
"())));");
- } else {
- // The object could be a custom action with an associated
+ } else if (varInfoNames.contains(name)) {
+ // The object is a custom action with an associated
// VariableInfo entry for this name.
// Get the class name and then introspect at runtime.
out
.printil("out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString"
+
"(org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty"
- + "(_jspx_page_context.getAttribute(\""
+ + "(_jspx_page_context.findAttribute(\""
+ name
- + "\", PageContext.PAGE_SCOPE), \""
+ + "\"), \""
+ property
+ "\")));");
+ } else {
+ StringBuilder msg =
+ new StringBuilder("jsp:getProperty for bean with name
'");
+ msg.append(name);
+ msg.append(
+ "'. Name was not previously introduced as per
JSP.5.3");
+
+ throw new JasperException(msg.toString());
}
n.setEndJavaLine(out.getJavaLine());
@@ -1799,6 +1810,18 @@
// restore previous writer
out = outSave;
}
+
+ // Add the named objects to the list of 'introduced' names to enable
+ // a later test as per JSP.5.3
+ VariableInfo[] infos = n.getVariableInfos();
+ if (infos != null && infos.length > 0) {
+ for (int i = 0; i < infos.length; i++) {
+ VariableInfo info = infos[i];
+ if (info != null && info.getVarName() != null)
+ pageInfo.getVarInfoNames().add(info.getVarName());
+ }
+ }
+
}
private static final String SINGLE_QUOTE = "'";
@@ -3386,6 +3409,7 @@
isPoolingEnabled = false;
}
beanInfo = pageInfo.getBeanRepository();
+ varInfoNames = pageInfo.getVarInfoNames();
breakAtLF = ctxt.getOptions().getMappedFile();
if (isPoolingEnabled) {
tagHandlerPoolNames = new Vector();
Modified: trunk/java/org/apache/jasper/compiler/PageInfo.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/PageInfo.java 2009-06-24 07:22:30 UTC (rev
1128)
+++ trunk/java/org/apache/jasper/compiler/PageInfo.java 2009-07-07 16:54:44 UTC (rev
1129)
@@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
import java.util.Vector;
import javax.el.ExpressionFactory;
@@ -43,6 +44,7 @@
private Vector dependants;
private BeanRepository beanRepository;
+ private Set<String> varInfoNames;
private HashMap taglibsMap;
private HashMap jspPrefixMapper;
private HashMap xmlPrefixMapper;
@@ -709,4 +711,8 @@
public void setTrimDirectiveWhitespaces(boolean trimDirectiveWhitespaces) {
this.trimDirectiveWhitespaces = trimDirectiveWhitespaces;
}
+
+ public Set<String> getVarInfoNames() {
+ return varInfoNames;
+ }
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-06-24 07:22:30 UTC (rev 1128)
+++ trunk/webapps/docs/changelog.xml 2009-07-07 16:54:44 UTC (rev 1129)
@@ -143,6 +143,9 @@
<fix>
<bug>47318</bug>: Process include preludes and codas when processing
directives and whole pages. (markt)
</fix>
+ <fix>
+ <bug>38797</bug>: Fix getProperty code to what it used to be in
Tomcat 5.5.12. (markt)
+ </fix>
</changelog>
</subsection>
</section>
Show replies by date