Example usage for org.apache.commons.jxpath.servlet Constants REQUEST_SCOPE

List of usage examples for org.apache.commons.jxpath.servlet Constants REQUEST_SCOPE

Introduction

In this page you can find the example usage for org.apache.commons.jxpath.servlet Constants REQUEST_SCOPE.

Prototype

String REQUEST_SCOPE

To view the source code for org.apache.commons.jxpath.servlet Constants REQUEST_SCOPE.

Click Source Link

Document

Variable name for javax.servlet.ServletRequest .

Usage

From source file:org.apache.cocoon.jxpath.JXPathCocoonContexts.java

/**
 * Returns a JXPathContext bound to the "request" scope.
 * Caches that context within the request itself.
 *///  ww w. jav  a2 s .c om
public final JXPathContext getRequestContext() {
    final Map objectModel = ContextHelper.getObjectModel(this.context);

    Request request = ObjectModelHelper.getRequest(objectModel);
    JXPathContext context = (JXPathContext) request.getAttribute(Constants.JXPATH_CONTEXT);
    if (context == null) {
        Context envContext = ObjectModelHelper.getContext(objectModel);
        JXPathContext parentContext = null;

        Session session = request.getSession(false);
        if (session != null) {
            parentContext = getSessionContext(session, envContext);
        } else {
            parentContext = getApplicationContext(envContext);
        }

        request = new RequestProxy(request);
        context = factory.newContext(parentContext, request);
        context.setVariables(new KeywordVariables(Constants.REQUEST_SCOPE, request));
        request.setAttribute(Constants.JXPATH_CONTEXT, context);
    }
    return context;
}