Example usage for javax.servlet.http HttpServletRequest getAttribute

List of usage examples for javax.servlet.http HttpServletRequest getAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getAttribute.

Prototype

public Object getAttribute(String name);

Source Link

Document

Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Usage

From source file:edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.java

public static RequestModelAccess on(HttpServletRequest req) {
    Object o = req.getAttribute(ATTRIBUTE_NAME);
    if (o instanceof RequestModelAccess) {
        return (RequestModelAccess) o;
    } else {/* ww w. j  a v a 2 s. co  m*/
        RequestModelAccess access = factory.buildRequestModelAccess(req);
        req.setAttribute(ATTRIBUTE_NAME, access);
        return access;
    }
}

From source file:net.hillsdon.reviki.web.pages.impl.TextFormatSearchResults.java

private static String getUrlForPage(final HttpServletRequest request, final String wiki, final String page)
        throws Exception {
    LinkResolutionContext resolver = (LinkResolutionContext) request
            .getAttribute(RequestAttributes.LINK_RESOLUTION_CONTEXT);
    return resolver.resolve(wiki, page).toString();
}

From source file:info.magnolia.cms.util.ServletUtil.java

/**
 * Returns the request uri for the request. If the request is an include it will return the uri being included. The
 * returned uri is not decoded./*www . ja v  a 2  s  .  c  om*/
 */
public static String getRequestUri(HttpServletRequest request) {
    if (request.getAttribute(INCLUDE_REQUEST_URI_ATTRIBUTE) != null)
        return (String) request.getAttribute(INCLUDE_REQUEST_URI_ATTRIBUTE);
    return request.getRequestURI();
}

From source file:info.magnolia.cms.util.ServletUtil.java

/**
 * Returns true if the request is currently processing a forward operation. This method will return false after
 * an include operation has begun and will return true after that include operations has completed.
 *//*from  ww w  .j  a  v  a  2  s  . c o m*/
public static boolean isForward(HttpServletRequest request) {
    return request.getAttribute(FORWARD_REQUEST_URI_ATTRIBUTE) != null && !isInclude(request);
}

From source file:info.magnolia.cms.util.ServletUtil.java

/**
 * Returns true if the request is currently processing an include operation.
 *//*from w w w.ja va2 s  . c  o m*/
public static boolean isInclude(HttpServletRequest request) {
    return request.getAttribute(INCLUDE_REQUEST_URI_ATTRIBUTE) != null;
}

From source file:info.magnolia.cms.util.ServletUtil.java

/**
 * Returns true if the request is rendering an error page, either due to a call to sendError() or an exception
 * being thrown in a filter or a servlet that reached the container. Will return true also after an include() or
 * forward() while rendering the error page.
 *///from   w  ww .  java  2s.  c om
public static boolean isError(HttpServletRequest request) {
    return request.getAttribute(ERROR_REQUEST_STATUS_CODE_ATTRIBUTE) != null;
}

From source file:info.magnolia.cms.util.ServletUtil.java

/**
 * Returns the original request uri. The If the request has been forwarded it finds the original request uri from
 * request attributes. The returned uri is not decoded.
 *///from  w ww.  java2s.  c o m
public static String getOriginalRequestURI(HttpServletRequest request) {
    if (request.getAttribute(FORWARD_REQUEST_URI_ATTRIBUTE) != null) {
        return (String) request.getAttribute(FORWARD_REQUEST_URI_ATTRIBUTE);
    }
    return request.getRequestURI();
}

From source file:grails.util.GrailsWebUtil.java

/**
 * Retrieves the URI from the request from either the include attribute or the request.getRequestURI() method.
 *
 * @param request The HttpServletRequest instance
 * @return The String URI//from   w  ww .  j av  a2 s. co  m
 */
public static String getUriFromRequest(HttpServletRequest request) {
    Object includeUri = request.getAttribute("javax.servlet.include.request_uri");
    return includeUri == null ? request.getRequestURI() : (String) includeUri;
}

From source file:grails.util.GrailsWebUtil.java

/**
 * Obtains the currently executing controller from the given request if any.
 * @param request The request object//from   ww  w . j av  a 2  s .  co  m
 * @return The controller or null
 */
public static GroovyObject getControllerFromRequest(HttpServletRequest request) {
    return (GroovyObject) request.getAttribute(GrailsApplicationAttributes.CONTROLLER);
}

From source file:org.avidj.zuul.rs.Zuul.java

private static List<String> getLockPath(HttpServletRequest request, String session) {
    String matchedPath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
    final int prefixLength = "/s/".length() + session.length();
    String lockPath = matchedPath.substring(prefixLength);
    if (lockPath.startsWith("/")) {
        lockPath = lockPath.substring(1);
    }/*from w w w .j a v a2s  . co  m*/
    return toLockPath(lockPath);
}