Example usage for javax.servlet.jsp PageContext SESSION_SCOPE

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

Introduction

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

Prototype

int SESSION_SCOPE

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

Click Source Link

Document

Session scope (only valid if this page participates in a session): the named reference remains available from the HttpSession (if any) associated with the Servlet until the HttpSession is invalidated.

Usage

From source file:com.geemvc.taglib.GeemvcTagSupport.java

protected int scope() {
    if (scope == null)
        return PageContext.PAGE_SCOPE;

    switch (scope.toLowerCase().trim()) {
    case REQUEST_SCOPE:
        return PageContext.REQUEST_SCOPE;
    case SESSION_SCOPE:
        return PageContext.SESSION_SCOPE;
    default:/* w  w  w .j  a v a 2 s .  c om*/
        return PageContext.PAGE_SCOPE;
    }
}

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  www.ja v  a  2s  .  c  om
        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   www. j av  a  2s  .  c  om*/
 * 
 * @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./*  ww w.j av  a 2 s. co 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 testDefineNameSessionScope() {
    pageContext.setAttribute(TEST_KEY, TEST_VALUE, PageContext.SESSION_SCOPE);
    runMyTest("testDefineNameSessionScope");
}

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

public void testDefineNamePropertySessionScope() {
    LabelValueBean lvb = new LabelValueBean("key", TEST_VALUE);
    pageContext.setAttribute(TEST_KEY, lvb, PageContext.SESSION_SCOPE);
    runMyTest("testDefineNamePropertySessionScope");
}

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

public void testDefineValueSessionScope() {
    LabelValueBean lvb = new LabelValueBean("key", TEST_VALUE + " this will be set to the correct value");
    pageContext.setAttribute(TEST_KEY, lvb, PageContext.SESSION_SCOPE);
    runMyTest("testDefineValueSessionScope");
}

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

private void runMyTest(String whichTest, Locale locale) {
    pageContext.setAttribute(Globals.LOCALE_KEY, locale, PageContext.SESSION_SCOPE);
    request.setAttribute("runTest", whichTest);
    try {//from w  ww .j  a  v  a2s  . c o m
        pageContext.forward("/test/org/apache/struts/taglib/bean/TestMessageTag.jsp");
    } catch (Exception e) {
        e.printStackTrace();
        fail("There is a problem that is preventing the tests to continue!");
    }
}

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

public void testMessageTagNoArgNamePropertySessionScopeDefaultBundle() {
    pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message"),
            PageContext.SESSION_SCOPE);
    runMyTest("testMessageTagNoArgNamePropertySessionScopeDefaultBundle", new Locale("", ""));
}

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

public void testMessageTagNoArgNamePropertySessionScopeAlternateBundle() {
    pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message"),
            PageContext.SESSION_SCOPE);
    runMyTest("testMessageTagNoArgNamePropertySessionScopeAlternateBundle", new Locale("", ""));
}