Author: markt
Date: Fri Jan 9 07:53:50 2009
New Revision: 733072
URL: http://svn.apache.org/viewvc?rev=733072&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46339
Before the invocation of a fragment, AT_BEGIN and NESTED variables should be
copied from the current JspContext to the JspContext of the fragment (*instead*
of the JspContext of the calling page or tag file).
Patch provided by [email protected]
TCK passes with this patch applied.
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
tomcat/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Generator.java?rev=733072&r1=733071&r2=733072&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Fri Jan 9
07:53:50 2009
@@ -2032,9 +2032,6 @@
n.setBeginJavaLine(out.getJavaLine());
- // Copy virtual page scope of tag file to page scope of invoking
- // page
- out.printil("((org.apache.jasper.runtime.JspContextWrapper)
this.jspContext).syncBeforeInvoke();");
String varReaderAttr = n.getTextAttribute("varReader");
String varAttr = n.getTextAttribute("var");
if (varReaderAttr != null || varAttr != null) {
@@ -2048,6 +2045,11 @@
out.print(toGetterMethod(n.getTextAttribute("fragment")));
out.println(" != null) {");
out.pushIndent();
+ // Copy virtual page scope of tag file to page scope of invoking
+ // page
+ out.printil("((org.apache.jasper.runtime.JspContextWrapper)
this.jspContext).syncBeforeInvoke(");
+ out.print(toGetterMethod(n.getTextAttribute("fragment")));
+ out.println(".getJspContext());");
out.printin(toGetterMethod(n.getTextAttribute("fragment")));
out.println(".invoke(_jspx_sout);");
out.popIndent();
Modified: tomcat/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java?rev=733072&r1=733071&r2=733072&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java
(original)
+++ tomcat/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java Fri Jan
9 07:53:50 2009
@@ -336,6 +336,16 @@
}
/**
+ * Synchronize variables before fragment invokation
+ * @param jspContext The JspContext the variable should sync to. This
+ * is usually the context of the page where the fragment is.
+ */
+ public void syncBeforeInvoke(JspContext jspContext) {
+ copyTagToPageScope(VariableInfo.NESTED, (PageContext)jspContext);
+ copyTagToPageScope(VariableInfo.AT_BEGIN, (PageContext)jspContext);
+ }
+
+ /**
* Synchronize variables at end of tag file
*/
public void syncEndTagFile() {
@@ -352,6 +362,17 @@
* variable scope (one of NESTED, AT_BEGIN, or AT_END)
*/
private void copyTagToPageScope(int scope) {
+ copyTagToPageScope(scope, invokingJspCtxt);
+ }
+
+ /**
+ * Copies the variables of the given scope from the virtual page scope of
+ * this JSP context wrapper to the page scope of the specified JSP context.
+ *
+ * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
+ * @param jspContext the target context
+ */
+ private void copyTagToPageScope(int scope, PageContext jspContext) {
Iterator<String> iter = null;
switch (scope) {
@@ -377,9 +398,9 @@
Object obj = getAttribute(varName);
varName = findAlias(varName);
if (obj != null) {
- invokingJspCtxt.setAttribute(varName, obj);
+ jspContext.setAttribute(varName, obj);
} else {
- invokingJspCtxt.removeAttribute(varName,
PAGE_SCOPE);
+ jspContext.removeAttribute(varName, PAGE_SCOPE);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]