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:de.hybris.platform.acceleratorcms.tags2.CMSContentSlotTag.java

protected void unExposeVariables() {
    pageContext.removeAttribute(varAttribute, PageContext.REQUEST_SCOPE);
    pageContext.removeAttribute("contentSlot", PageContext.REQUEST_SCOPE);
    pageContext.removeAttribute("elementPos", PageContext.REQUEST_SCOPE);
    pageContext.removeAttribute("isFirstElement", PageContext.REQUEST_SCOPE);
    pageContext.removeAttribute("isLastElement", PageContext.REQUEST_SCOPE);
    pageContext.removeAttribute("numberOfElements", PageContext.REQUEST_SCOPE);
}

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

/**
 * Writes the opening part of the block   '<code>form</code>' tag and exposes
 * the form object name in the {@link javax.servlet.jsp.PageContext}.
 * @param tagWriter the {@link TagWriter} to which the form content is to be written
 * @return {@link javax.servlet.jsp.tagext.Tag#EVAL_BODY_INCLUDE}
 *//* w ww.  j a v  a  2  s  .co m*/
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
    this.tagWriter = tagWriter;

    tagWriter.startTag(FORM_TAG);
    writeDefaultAttributes(tagWriter);
    tagWriter.writeAttribute(ACTION_ATTRIBUTE, resolveAction());
    writeOptionalAttribute(tagWriter, METHOD_ATTRIBUTE,
            isMethodBrowserSupported(getMethod()) ? getMethod() : DEFAULT_METHOD);
    writeOptionalAttribute(tagWriter, TARGET_ATTRIBUTE, getTarget());
    writeOptionalAttribute(tagWriter, ENCTYPE_ATTRIBUTE, getEnctype());
    writeOptionalAttribute(tagWriter, ACCEPT_CHARSET_ATTRIBUTE, getAcceptCharset());
    writeOptionalAttribute(tagWriter, ONSUBMIT_ATTRIBUTE, getOnsubmit());
    writeOptionalAttribute(tagWriter, ONRESET_ATTRIBUTE, getOnreset());
    writeOptionalAttribute(tagWriter, AUTOCOMPLETE_ATTRIBUTE, getAutocomplete());

    tagWriter.forceBlock();

    if (!isMethodBrowserSupported(getMethod())) {

        String composedValue = dataComposer.compose(getMethodParameter(), getMethod(), false);

        tagWriter.startTag(INPUT_TAG);
        writeOptionalAttribute(tagWriter, TYPE_ATTRIBUTE, "hidden");
        writeOptionalAttribute(tagWriter, NAME_ATTRIBUTE, getMethodParameter());
        writeOptionalAttribute(tagWriter, VALUE_ATTRIBUTE, composedValue);
        tagWriter.endTag();
    }

    // Expose the form object name for nested tags...
    String modelAttribute = resolveModelAttribute();
    this.pageContext.setAttribute(MODEL_ATTRIBUTE_VARIABLE_NAME, modelAttribute, PageContext.REQUEST_SCOPE);
    this.pageContext.setAttribute(COMMAND_NAME_VARIABLE_NAME, modelAttribute, PageContext.REQUEST_SCOPE);

    // Save previous nestedPath value, build and expose current nestedPath value.
    // Use request scope to expose nestedPath to included pages too.
    this.previousNestedPath = (String) this.pageContext.getAttribute(NESTED_PATH_VARIABLE_NAME,
            PageContext.REQUEST_SCOPE);
    this.pageContext.setAttribute(NESTED_PATH_VARIABLE_NAME,
            modelAttribute + PropertyAccessor.NESTED_PROPERTY_SEPARATOR, PageContext.REQUEST_SCOPE);

    return EVAL_BODY_INCLUDE;
}

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

public Class<?> controllerClass() {
    return (Class<?>) jspContext.getAttribute(GeemvcKey.CONTROLLER_CLASS, PageContext.REQUEST_SCOPE);
}

From source file:de.innovationgate.wgpublisher.webtml.Include.java

private void performStaticTMLInclude() throws TMLException {

    Status status = (Status) getStatus();

    // Locate resource
    String tmlName = status.ref;//from ww  w  . j  ava 2 s  .c  o  m
    if (tmlName == null || tmlName.equals("")) {
        throw new TMLException("Could not retrieve result of included static resource. No reference given.");
    }

    String jspPath = "/static/tml/" + tmlName + ".jsp";

    // Perform include
    String oldDesignDB = (String) getOption(Base.OPTION_DESIGNDB);
    this.pageContext.setAttribute(ATTRIB_INCLUDEPARENT, status, PageContext.REQUEST_SCOPE);
    getStatus().setOption(Base.OPTION_DESIGNDB, oldDesignDB, null);
    try {
        this.pageContext.include(jspPath);
    } catch (Exception e) {
        throw new TMLException("Error executing static tml module \"" + tmlName + "\"", e, false);
    } finally {
        this.pageContext.setAttribute(ATTRIB_INCLUDEPARENT, null, PageContext.REQUEST_SCOPE);
        getStatus().setOption(Base.OPTION_DESIGNDB, oldDesignDB, null);
    }

    // Import the included root tag result
    if (status.rootTag != null) {
        this.setResult(status.rootTag.result);
        status.rootTag.result = null;
    } else {
        throw new TMLException("Could not retrieve result of included static resource: " + tmlName);
    }

}

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

public Method handlerMethod() {
    return (Method) jspContext.getAttribute(GeemvcKey.HANDLER_METHOD, PageContext.REQUEST_SCOPE);
}

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

public RequestContext requestContext() {
    return (RequestContext) jspContext.getAttribute(GeemvcKey.REQUEST_CONTEXT, PageContext.REQUEST_SCOPE);
}

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

public Errors validationErrors() {
    return (Errors) jspContext.getAttribute(GeemvcKey.VALIDATION_ERRORS, PageContext.REQUEST_SCOPE);
}

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

public Notices notices() {
    return (Notices) jspContext.getAttribute(GeemvcKey.NOTICES, PageContext.REQUEST_SCOPE);
}

From source file:com.glaf.core.tag.TagUtils.java

/**
 * Returns the appropriate MessageResources object for the current module
 * and the given bundle.//from w  ww .j  av a2s.  c  o  m
 * 
 * @param pageContext
 *            Search the context's scopes for the resources.
 * @param bundle
 *            The bundle name to look for. If this is <code>null</code>, the
 *            default bundle name is used.
 * @param checkPageScope
 *            Whether to check page scope
 * @return MessageResources The bundle's resources stored in some scope.
 * @throws JspException
 *             if the MessageResources object could not be found.
 */
public MessageResources retrieveMessageResources(PageContext pageContext, String bundle, boolean checkPageScope)
        throws JspException {
    MessageResources resources = null;

    if (bundle == null) {
        bundle = conf.get("i18n.messages_key");
    }

    if (bundle == null) {
        bundle = Globals.MESSAGES_KEY;
    }

    if (checkPageScope) {
        resources = (MessageResources) pageContext.getAttribute(bundle, PageContext.PAGE_SCOPE);
    }

    if (resources == null) {
        resources = (MessageResources) pageContext.getAttribute(bundle, PageContext.REQUEST_SCOPE);
    }

    if (resources == null) {
        resources = (MessageResources) pageContext.getAttribute(bundle, PageContext.APPLICATION_SCOPE);
    }

    if (resources == null) {
        resources = (MessageResources) pageContext.getAttribute(Globals.DEFAULT_RESOURCE_NAME,
                PageContext.APPLICATION_SCOPE);
        if (resources == null) {
            resources = PropertyMessageResourcesFactory.createFactory()
                    .createResources(Globals.DEFAULT_RESOURCE_NAME);
            pageContext.setAttribute(Globals.DEFAULT_RESOURCE_NAME, resources, PageContext.APPLICATION_SCOPE);
        }
    }

    if (resources == null) {
        JspException e = new JspException(messages.getMessage("message.bundle", bundle));

        saveException(pageContext, e);
        throw e;
    }

    return resources;
}

From source file:com.glaf.core.tag.TagUtils.java

/**
 * Save the specified exception as a request attribute for later use.
 * //from  w w w.  ja  v  a  2 s  .c  om
 * @param pageContext
 *            The PageContext for the current page
 * @param exception
 *            The exception to be saved
 */
public void saveException(PageContext pageContext, Throwable exception) {
    pageContext.setAttribute(Globals.EXCEPTION_KEY, exception, PageContext.REQUEST_SCOPE);
}