Example usage for javax.servlet.jsp PageContext REQUEST_SCOPE

List of usage examples for javax.servlet.jsp PageContext REQUEST_SCOPE

Introduction

In this page you can find the example usage for javax.servlet.jsp PageContext REQUEST_SCOPE.

Prototype

int REQUEST_SCOPE

To view the source code for javax.servlet.jsp PageContext REQUEST_SCOPE.

Click Source Link

Document

Request scope: the named reference remains available from the ServletRequest associated with the Servlet until the current request is completed.

Usage

From source file:org.hdiv.web.servlet.tags.form.FormTagHDIV.java

/**
 * Clears the stored {@link TagWriter}.//w  ww  .ja va2 s  .  co m
 */
@Override
public void doFinally() {
    super.doFinally();
    this.pageContext.removeAttribute(MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    this.pageContext.removeAttribute(COMMAND_NAME_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    if (this.previousNestedPath != null) {
        // Expose previous nestedPath value.
        this.pageContext.setAttribute(NESTED_PATH_VARIABLE_NAME, this.previousNestedPath,
                PageContext.REQUEST_SCOPE);
    } else {
        // Remove exposed nestedPath value.
        this.pageContext.removeAttribute(NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    }
    this.tagWriter = null;
    this.previousNestedPath = null;
}

From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java

public static String getRequestId(PageContext pageContext) {
    return (String) pageContext.getAttribute(FormTag.REQUEST_ID_ATTRIBUTE_NAME, PageContext.REQUEST_SCOPE);
}

From source file:org.sakaiproject.iclicker.tool.ToolController.java

@SuppressWarnings("unchecked")
public static void addMessage(PageContext context, String key, String message) {
    if (context == null || key == null) {
        throw new IllegalArgumentException(
                "context (" + context + ") and key (" + key + ") must both not be null");
    }/*from w w  w .  ja  v a2s.  c  om*/
    if (message != null && !"".equals(message)) {
        String keyVal = ICLICKER_MESSAGES + key;
        if (context.getAttribute(keyVal) == null) {
            context.setAttribute(keyVal, new Vector<String>(), PageContext.REQUEST_SCOPE);
        }
        List<String> l = (List<String>) context.getAttribute(keyVal, PageContext.REQUEST_SCOPE);
        l.add(message);
    }
}

From source file:org.sakaiproject.iclicker.tool.ToolController.java

@SuppressWarnings("unchecked")
public static String[] getMessages(PageContext context, String key) {
    if (context == null || key == null) {
        throw new IllegalArgumentException(
                "context (" + context + ") and key (" + key + ") must both not be null");
    }/* ww w .  ja v  a2  s .c o m*/
    String[] messages;
    String keyVal = ICLICKER_MESSAGES + key;
    if (context.getAttribute(keyVal, PageContext.REQUEST_SCOPE) == null) {
        messages = new String[] {};
    } else {
        List<String> l = (List<String>) context.getAttribute(keyVal, PageContext.REQUEST_SCOPE);
        messages = l.toArray(new String[l.size()]);
    }
    return messages;
}

From source file:com.adito.core.CoreUtil.java

/**
 * @param pageContext//from  w w w . j  a va2s .  c o m
 */
public static void dumpComponentContext(PageContext pageContext) {
    ComponentContext compContext = (ComponentContext) pageContext
            .getAttribute(ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE);
    if (log.isInfoEnabled())
        log.info("Component context dump");
    for (Iterator e = compContext.getAttributeNames(); e.hasNext();) {
        String n = (String) e.next();
        Object value = compContext.getAttribute(n);
        if (log.isInfoEnabled())
            log.info("   " + n + " = " + value);
    }
}

From source file:com.adito.core.CoreUtil.java

/**
 * Dump tile attributes to {@link System#err}.
 * // www.  ja v a 2s  .  c om
 * @param pageContext page context from which to get tile.
 */
public static void dumpTileScope(PageContext pageContext) {
    ComponentContext compContext = (ComponentContext) pageContext
            .getAttribute(ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE);
    System.err.println("Tile attributes");
    for (Iterator i = compContext.getAttributeNames(); i.hasNext();) {
        String n = (String) i.next();
        System.err.println("   " + n + " = " + compContext.getAttribute(n));
    }
}

From source file:nl.strohalm.cyclos.taglibs.AbstractEscapeTag.java

public void setScope(String scope) {
    scope = StringUtils.trimToNull(scope);
    if ("application".equalsIgnoreCase(scope)) {
        this.scope = PageContext.APPLICATION_SCOPE;
    } else if ("session".equalsIgnoreCase(scope)) {
        this.scope = PageContext.SESSION_SCOPE;
    } else if ("request".equalsIgnoreCase(scope)) {
        this.scope = PageContext.REQUEST_SCOPE;
    } else {/*from w  w w.j a  v a 2  s  .  c o m*/
        this.scope = PageContext.PAGE_SCOPE;
    }
}

From source file:org.apache.cactus.extension.jsp.JspTagLifecycle.java

/**
 * Adds a special expectation that verifies that a specific scoped variable
 * is exposed in the body of the tag./*from   w w  w . j  a va 2  s . c  o m*/
 * 
 * @param theName The name of the variable
 * @param theExpectedValues An ordered list containing the expected values 
 *        values of the scoped variable, one for each expected iteration
 *        step
 * @param theScope The scope under which the variable is stored
 */
public void expectScopedVariableExposed(String theName, Object[] theExpectedValues, int theScope) {
    if ((theName == null) || (theExpectedValues == null)) {
        throw new NullPointerException();
    }
    if (theExpectedValues.length == 0) {
        throw new IllegalArgumentException();
    }
    if ((theScope != PageContext.PAGE_SCOPE) && (theScope != PageContext.REQUEST_SCOPE)
            && (theScope != PageContext.SESSION_SCOPE) && (theScope != PageContext.APPLICATION_SCOPE)) {
        throw new IllegalArgumentException();
    }
    addInterceptor(new ExpectScopedVariableExposedInterceptor(theName, theExpectedValues, theScope));
}

From source file:org.apache.sling.scripting.jsp.taglib.IncludeTagHandler.java

/**
 * Gets the int code for a valid scope, must be one of 'page', 'request',
 * 'session' or 'application'. If an invalid or no scope is specified page
 * scope is returned./*w w w  .j  a  va  2s . c  o  m*/
 * 
 * @param scope
 * @return
 */
private Integer validScope(String scope) {
    scope = (scope != null && scope.trim().length() > 0 ? scope.trim().toUpperCase() : null);
    if (scope == null) {
        return PageContext.PAGE_SCOPE;
    }

    String[] scopes = { "PAGE", "REQUEST", "SESSION", "APPLICATION" };
    Integer[] iaScopes = { PageContext.PAGE_SCOPE, PageContext.REQUEST_SCOPE, PageContext.SESSION_SCOPE,
            PageContext.APPLICATION_SCOPE };

    for (int ndx = 0, len = scopes.length; ndx < len; ndx++) {
        if (scopes[ndx].equals(scope)) {
            return iaScopes[ndx];
        }
    }
    return PageContext.PAGE_SCOPE;
}

From source file:org.apache.struts.taglib.bean.TestDefineTag.java

public void testDefineNameRequestScope() {
    pageContext.setAttribute(TEST_KEY, TEST_VALUE, PageContext.REQUEST_SCOPE);
    runMyTest("testDefineNameRequestScope");
}