List of usage examples for javax.servlet.jsp PageContext getVariableResolver
public abstract VariableResolver getVariableResolver();
From source file:io.undertow.test.jsp.expression.ExpressionJspTestCase.java
public static void evaluate(JspWriter out, PageContext pc, String qualifiedMethodExpression, String unqualifiedMethodExpression, String variableExpression) throws Exception { assert pc != null; TSFunctionMapper mapper = new TSFunctionMapper(); ExpressionEvaluator eval = pc.getExpressionEvaluator(); VariableResolver resolver = pc.getVariableResolver(); assert eval != null : "Unable to obtain ExpressionEvaluator"; Expression expr = eval.parseExpression(qualifiedMethodExpression, java.lang.String.class, mapper); assert expr != null; String result = (String) expr.evaluate(resolver); if (result != null) { if (result.equals("string")) { Expression expr2 = eval.parseExpression(variableExpression, javax.servlet.jsp.PageContext.class, null);/*from w ww . ja v a 2 s . com*/ if (expr2 != null) { PageContext pageContext = (PageContext) expr2.evaluate(resolver); if (pageContext != pc) { out.println("Test FAILED. Resolution didn't return expected value."); out.println("PageContext returned is not the same instance as expected."); } Expression expr3 = eval.parseExpression(unqualifiedMethodExpression, java.lang.String.class, mapper); if (expr3 != null) { result = (String) expr3.evaluate(resolver); if (result != null) { if (result.equals("string")) { out.println("Test PASSED"); } else { out.println("Test FAILED. (l3) Expression evaluation returned unexpected value."); out.println("Expected 'string', received '" + result + "'"); } } else { out.println("Test FAILED. (l3) Expression evaluation returned null."); } } else { out.println("Test FAILED. (l3) ExpressionEvaluator.parseExpression" + " returned null."); } } else { out.println("Test FAILED. (l2) ExpressionEvaluator returned null."); } } else { out.println("Test FAILED. (l1) Expression evaluation returned unexpected result."); out.println("Expected 'string', Received '" + result + "'"); } } else { out.println("Test FAILED. (l1) Expression evaluation returned null."); } }
From source file:org.apache.jasper.runtime.PageContextImpl.java
/** * Proprietary method to evaluate EL expressions. * XXX - This method should go away once the EL interpreter moves * out of JSTL and into its own project. For now, this is necessary * because the standard machinery is too slow. * * @param expression The expression to be evaluated * @param expectedType The expected resulting type * @param pageContext The page context// www. ja v a2 s .co m * @param functionMap Maps prefix and name to Method * @return The result of the evaluation */ public static Object proprietaryEvaluate(final String expression, final Class expectedType, final PageContext pageContext, final ProtectedFunctionMapper functionMap, final boolean escape) throws ELException { Object retValue; if (System.getSecurityManager() != null) { try { retValue = AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { return elExprEval.evaluate(expression, expectedType, pageContext.getVariableResolver(), functionMap); } }); } catch (PrivilegedActionException ex) { Exception realEx = ex.getException(); if (realEx instanceof ELException) { throw (ELException) realEx; } else { throw new ELException(realEx); } } } else { retValue = elExprEval.evaluate(expression, expectedType, pageContext.getVariableResolver(), functionMap); } if (escape) { retValue = XmlEscape(retValue.toString()); } return retValue; }
From source file:org.apache.struts2.jasper.runtime.PageContextImpl.java
/** * Proprietary method to evaluate EL expressions. * XXX - This method should go away once the EL interpreter moves * out of JSTL and into its own project. For now, this is necessary * because the standard machinery is too slow. * * @param expression The expression to be evaluated * @param expectedType The expected resulting type * @param pageContext The page context//from ww w . j a v a 2s .c o m * @param functionMap Maps prefix and name to Method * @return The result of the evaluation */ public static Object proprietaryEvaluate(final String expression, final Class expectedType, final PageContext pageContext, final ProtectedFunctionMapper functionMap, final boolean escape) throws ELException { Object retValue; if (SecurityUtil.isPackageProtectionEnabled()) { try { retValue = AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { return elExprEval.evaluate(expression, expectedType, pageContext.getVariableResolver(), functionMap); } }); } catch (PrivilegedActionException ex) { Exception realEx = ex.getException(); if (realEx instanceof ELException) { throw (ELException) realEx; } else { throw new ELException(realEx); } } } else { retValue = elExprEval.evaluate(expression, expectedType, pageContext.getVariableResolver(), functionMap); } if (escape) { retValue = XmlEscape(retValue.toString()); } return retValue; }
From source file:org.emonocot.portal.view.Functions.java
public static String evaluate(String expressionString, PageContext pageContext) throws ELException { return (String) pageContext.getExpressionEvaluator().evaluate(expressionString, String.class, pageContext.getVariableResolver(), null); }