https://issues.apache.org/bugzilla/show_bug.cgi?id=52776

             Bug #: 52776
           Summary: Generator's JspFragment.invoke implementation does not
                    reset ELContext[JspContext.class]
           Product: Tomcat 7
           Version: 7.0.26
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Jasper
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: k...@xk72.com
    Classification: Unclassified


If a developer captures a JspFragment themselves and calls invoke on it, the
JspContext.class attribute in the enclosing pageContext's ELContext is set by
the generated JspFragment subclass, but not reset to its original value
afterwards. Therefore after invoking a JspContext any EL expressions will be
searching the wrong jspContext for attribute values.

org.apache.jasper.compiler.Generator is responsible for creating the
JspFragment subclass to represent the compiled fragment. The
generatePostamble() method emits generated code to set the JspContext attribute
in the ELContext:

out.printil("this.jspContext.getELContext().putContext(javax.servlet.jsp.JspContext.class,this.jspContext);");

However it doesn't later put back the original value.

If you are using the <jsp:invoke> tag to invoke the fragment (which is
undoubtedly what most people are doing) then the code generated by
visit(Node.InvokeAction n) in Generator explicitly restores the EL context:

out.printil("jspContext.getELContext().putContext(javax.servlet.jsp.JspContext.class,getJspContext());");

However if you call invoke(Writer) on the JspFragment yourself you don't get
that tidy up code.

I suggest the resolution is to have the JspFragment.invoke method tidy up after
itself. It "puts" the change to the JspContext.class attribute so it should
also re"put" it. Then there shouldn't be any need to restore the EL context in
the generated <jsp:invoke> code.

I have tested this solution successfully.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to