Search in sources :

Example 21 with PageContext

use of javax.servlet.jsp.PageContext in project sling by apache.

the class JspFactoryImpl method internalGetPageContext.

private PageContext internalGetPageContext(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoflush) {
    try {
        PageContext pc = new PageContextImpl();
        pc.initialize(servlet, request, response, errorPageURL, needsSession, bufferSize, autoflush);
        return pc;
    } catch (Throwable ex) {
        /* FIXME: need to do something reasonable here!! */
        log.fatal("Exception initializing page context", ex);
        return null;
    }
}
Also used : PageContext(javax.servlet.jsp.PageContext)

Example 22 with PageContext

use of javax.servlet.jsp.PageContext in project opennms by OpenNMS.

the class EvaluationTest method runTests.

// -------------------------------------
/**
 * Runs the tests, reading expressions from pIn and writing the
 * results to pOut.
 */
public static void runTests(DataInput pIn, PrintStream pOut) throws IOException {
    PageContext context = createTestContext();
    while (true) {
        String str = pIn.readLine();
        if (str == null)
            break;
        if (str.startsWith("#") || "".equals(str.trim())) {
            pOut.println(str);
        } else {
            String typeStr = pIn.readLine();
            pOut.println("Expression: " + str);
            try {
                Class cl = parseClassName(typeStr);
                pOut.println("ExpectedType: " + cl);
                Evaluator e = new Evaluator();
                Object val = e.evaluate("test", str, cl, null, context);
                pOut.println("Evaluates to: " + val);
                if (val != null) {
                    pOut.println("With type: " + val.getClass().getName());
                }
                pOut.println();
            } catch (JspException exc) {
                pOut.println("Causes an error: " + exc);
            } catch (ClassNotFoundException exc) {
                pOut.println("Causes an error: " + exc);
            }
        }
    }
}
Also used : JspException(javax.servlet.jsp.JspException) PageContext(javax.servlet.jsp.PageContext) Evaluator(org.apache.taglibs.standard.lang.jstl.Evaluator)

Example 23 with PageContext

use of javax.servlet.jsp.PageContext in project tomcat70 by apache.

the class ImplicitObjectELResolver method getValue.

@Override
public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException {
    if (context == null) {
        throw new NullPointerException();
    }
    if (base == null && property != null) {
        int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
        if (idx >= 0) {
            PageContext page = (PageContext) context.getContext(JspContext.class);
            context.setPropertyResolved(true);
            switch(idx) {
                case APPLICATIONSCOPE:
                    return ScopeManager.get(page).getApplicationScope();
                case COOKIE:
                    return ScopeManager.get(page).getCookie();
                case HEADER:
                    return ScopeManager.get(page).getHeader();
                case HEADERVALUES:
                    return ScopeManager.get(page).getHeaderValues();
                case INITPARAM:
                    return ScopeManager.get(page).getInitParam();
                case PAGECONTEXT:
                    return ScopeManager.get(page).getPageContext();
                case PAGESCOPE:
                    return ScopeManager.get(page).getPageScope();
                case PARAM:
                    return ScopeManager.get(page).getParam();
                case PARAM_VALUES:
                    return ScopeManager.get(page).getParamValues();
                case REQUEST_SCOPE:
                    return ScopeManager.get(page).getRequestScope();
                case SESSION_SCOPE:
                    return ScopeManager.get(page).getSessionScope();
            }
        }
    }
    return null;
}
Also used : JspContext(javax.servlet.jsp.JspContext) PageContext(javax.servlet.jsp.PageContext)

Example 24 with PageContext

use of javax.servlet.jsp.PageContext in project tomcat70 by apache.

the class ScopedAttributeELResolver method getValue.

@Override
public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException {
    if (context == null) {
        throw new NullPointerException();
    }
    if (base == null) {
        context.setPropertyResolved(true);
        if (property != null) {
            String key = property.toString();
            PageContext page = (PageContext) context.getContext(JspContext.class);
            return page.findAttribute(key);
        }
    }
    return null;
}
Also used : JspContext(javax.servlet.jsp.JspContext) PageContext(javax.servlet.jsp.PageContext)

Example 25 with PageContext

use of javax.servlet.jsp.PageContext in project tomcat70 by apache.

the class ScopedAttributeELResolver method setValue.

@Override
public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException {
    if (context == null) {
        throw new NullPointerException();
    }
    if (base == null) {
        context.setPropertyResolved(true);
        if (property != null) {
            String key = property.toString();
            PageContext page = (PageContext) context.getContext(JspContext.class);
            int scope = page.getAttributesScope(key);
            if (scope != 0) {
                page.setAttribute(key, value, scope);
            } else {
                page.setAttribute(key, value);
            }
        }
    }
}
Also used : JspContext(javax.servlet.jsp.JspContext) PageContext(javax.servlet.jsp.PageContext)

Aggregations

PageContext (javax.servlet.jsp.PageContext)36 JspContext (javax.servlet.jsp.JspContext)12 JspWriter (javax.servlet.jsp.JspWriter)10 IOException (java.io.IOException)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 ArrayList (java.util.ArrayList)5 JspException (javax.servlet.jsp.JspException)5 FeatureDescriptor (java.beans.FeatureDescriptor)3 Test (org.junit.Test)2 BannedPeer (i2p.bote.network.BannedPeer)1 DhtPeerStats (i2p.bote.network.DhtPeerStats)1 DhtPeerStatsRow (i2p.bote.network.DhtPeerStatsRow)1 RelayPeer (i2p.bote.network.RelayPeer)1 PrintWriter (java.io.PrintWriter)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1