Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ELContext save/restore after fragment helper invoke #474

merged 1 commit into from
Feb 15, 2022


Copy link

It seems that ELContextWrapper.getContext() and ELContextWrapper.putContext() are out of sync with each other. ELContextWrapper.getContext() in its current implementation always returns current page context, and in a custom tag with fragment Helper the generated code corrupts parent ELContext. The generated custom tag code results in current page context always propogated to invoker evaluation context after helper invokation. Here is custom tag code commented to illustrate the problem:

    public void invoke( writer )
      throws javax.servlet.jsp.JspException
      javax.servlet.jsp.JspWriter out = null;
      if( writer != null ) {
        out = this.jspContext.pushBody(writer);
      } else {
        out = this.jspContext.getOut();
      try {
      // Does not work as suggested because ELContextWrapper always returns current page context
      try {
        Object _jspx_saved_JspContext = this.jspContext.getELContext().getContext(javax.servlet.jsp.JspContext.class);
        // Pointless with ELContextWrapper, as ELContextWrapper will return the current page context anyway
        switch( this.discriminator ) {
        // Here the invoker (parent) ELContext gets corrupted instead of being restored

The propose is not to put ELContext to parent in ELContextWrapper .

        public void putContext(@SuppressWarnings("rawtypes") Class key, Object contextObject) {
            if (key != JspContext.class) {
                wrapped.putContext(key, contextObject);

Copy link

Thanks for the PR.

@markt-asf markt-asf merged commit d4f1666 into apache:main Feb 15, 2022
markt-asf added a commit that referenced this pull request Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
2 participants