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

a ClassCastException is thrown when EL is used in conjunction with a custom PageContext wrapper #7

Open
glassfishrobot opened this issue Mar 4, 2016 · 5 comments

Comments

@glassfishrobot
Copy link

The following method in org.apache.jasper.runtime.PageContextImpl

private static ExpressionFactory getExpressionFactory(
            PageContext pageContext) {

        PageContextImpl pc =
            (PageContextImpl) JspContextWrapper.getRootPageContext(pageContext);
        return pc.getJspApplicationContext().getExpressionFactory();
    }

results in the exception.

However, it's possible to accomplish the exact same thing in a compliant way, without a cast, using:

JspApplicationContext jspApplicationContext =
            JspFactory.getDefaultFactory().getJspApplicationContext(
pageContext.getServletContext());

        return jspApplicationContext.getExpressionFactory();

Environment

any

Affected Versions

[current]

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Reported by rotty

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Was assigned to super_glassfish

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
rotty said:
I would attach a patch file.. but I can't seem to attach files any more:

commit dde29b0287e90efa8ff4eb27b332f4b54b88dd12
Author: Raymond Auge <[email protected]>
Date:   Fri Mar 4 11:42:17 2016 -0500

    Get ExpressionFactory without cast

    Signed-off-by: Raymond Auge <[email protected]>

diff --git a/impl/src/main/java/org/apache/jasper/runtime/PageContextImpl.java b/impl/src/main/java/org/apache/jasper/runtime/PageContextImpl.java
index 3365f42..a7a17e7 100644
--- a/impl/src/main/java/org/apache/jasper/runtime/PageContextImpl.java
+++ b/impl/src/main/java/org/apache/jasper/runtime/PageContextImpl.java
@@ -958,9 +958,11 @@ public class PageContextImpl extends PageContext {
     private static ExpressionFactory getExpressionFactory(
             PageContext pageContext) {

-        PageContextImpl pc =
-            (PageContextImpl) JspContextWrapper.getRootPageContext(pageContext);
-        return pc.getJspApplicationContext().getExpressionFactory();
+        JspApplicationContext jspApplicationContext =
+            JspFactory.getDefaultFactory().getJspApplicationContext(
+pageContext.getServletContext());
+
+        return jspApplicationContext.getExpressionFactory();
     }

     /**

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JSP-49

@glassfishrobot
Copy link
Author

@glassfishrobot glassfishrobot self-assigned this Aug 17, 2018
@markt-asf markt-asf transferred this issue from jakartaee/pages Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant