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:com.jjw.cloudymvc.web.mvc.ElementRequestCondition.java

@Override
public ElementRequestCondition getMatchingCondition(HttpServletRequest request) {
    String element = (String) request.getAttribute("element");
    Version version = (Version) request.getAttribute("version");

    // no element set, so no token, or an invalid token was passed to our API
    if (StringUtils.isEmpty(element)) {
        if (isTokenRequired) {
            return null;
        }/*from  w ww.  ja  va  2s.  c o m*/

        if (isSecretRequired) {
            assert request.getAttribute("user") != null;
            assert request.getAttribute("organization") != null;
            return this;
        }

        return this;
    }

    if (this.elementName.equals(element) && equalsMyVersionOrAPreviousVersion(version)) {
        return this;
    }

    return null;
}

From source file:nl.surfnet.coin.selfservice.control.identity.IdentityController.java

private Boolean isDashBoard(HttpServletRequest request) {
    return (Boolean) request.getAttribute("isDashBoard");
}

From source file:net.sourceforge.subsonic.theme.SubsonicThemeResolver.java

/**
* Resolve the current theme name via the given request.
*
* @param request Request to be used for resolution
* @return The current theme name/*from w  w  w .  jav  a2  s.c o m*/
*/
public String resolveThemeName(HttpServletRequest request) {
    String themeId = (String) request.getAttribute("subsonic.theme");
    if (themeId != null) {
        return themeId;
    }

    // Optimization: Cache theme in the request.
    themeId = doResolveThemeName(request);
    request.setAttribute("subsonic.theme", themeId);

    return themeId;
}

From source file:org.smigo.log.LogController.java

@RequestMapping(value = "/error")
public String error(Model model, HttpServletRequest request, HttpServletResponse response) {
    Exception ex = (Exception) request.getAttribute("javax.servlet.error.exception");
    logHandler.logError(request, response, ex, "Outside Spring MVC");
    model.addAttribute("statusCode", request.getAttribute("javax.servlet.error.status_code"));
    return "error.jsp";
}

From source file:com.hp.autonomy.frontend.find.core.web.CustomErrorController.java

@RequestMapping(DispatcherServletConfiguration.SERVER_ERROR_PATH)
public ModelAndView serverErrorPage(final HttpServletRequest request, final HttpServletResponse response) {
    final Exception exception = (Exception) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);

    return controllerUtils.buildErrorModelAndView(new ErrorModelAndViewInfo.Builder().setRequest(request)
            .setMainMessageCode(MESSAGE_CODE_INTERNAL_SERVER_ERROR_MAIN)
            .setSubMessageCode(MESSAGE_CODE_INTERNAL_SERVER_ERROR_SUB).setSubMessageArguments(null)
            .setStatusCode(response.getStatus()).setContactSupport(true).setButtonHref(getErrorUrl(request))
            .setException(exception).build());
}

From source file:com.goldengekko.meetr.web.MultiplexInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    Object principal = request.getAttribute(SecurityInterceptor.ATTR_NAME_PRINCIPAL);
    if (null != principal && principal instanceof DAppDomain) {
        final DAppDomain domain = (DAppDomain) principal;
        final String mux = domain.getAppArg1();
        LOG.debug("Setting MUX to {}", mux);
        MultiplexCrudService.setMultiplexKey(mux);
    }/*from   w w  w .  java 2 s.c  om*/
    return true;
}

From source file:com.netflix.spinnaker.gate.controllers.EntityTagsController.java

@RequestMapping(value = "/**", method = RequestMethod.GET)
public Map get(HttpServletRequest request) {
    String pattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
    String id = new AntPathMatcher().extractPathWithinPattern(pattern, request.getServletPath());

    return entityTagsService.get(id);
}

From source file:com.nominanuda.springmvc.JettyChainableDispatcherServlet.java

@Override
protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
    super.doDispatch(request, response);
    if (request.getAttribute(UNHANDLED_REQUEST) != null) {
        noHandlerFound(request, response);
    }/*  ww  w .j  a v  a 2 s .  c  o m*/
}

From source file:fi.hsl.parkandride.front.RequestLoggingInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    Optional.ofNullable((String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE))
            .filter(s -> s.startsWith(UrlSchema.API)).ifPresent(urlPattern -> {
                final String source = request.getHeader(SOURCE_HEADER);
                logger.trace("Intercepted API call: <{}> for source <{}>", urlPattern, source);
                batchingRequestLogService.increment(new RequestLogKey(urlPattern, source, DateTime.now()));
            });//w ww.  j av  a 2 s. co m
    return super.preHandle(request, response, handler);
}

From source file:de.blizzy.documentr.web.access.AccessController.java

@RequestMapping(value = "/login/forbidden", method = RequestMethod.GET)
@PreAuthorize("permitAll")
public String loginForbidden(HttpServletRequest request, Model model) {
    AccessDeniedException exception = (AccessDeniedException) request
            .getAttribute(WebAttributes.ACCESS_DENIED_403);
    String msg = getMessage(exception);
    if (StringUtils.isNotBlank(msg)) {
        model.addAttribute("errorMessage", msg); //$NON-NLS-1$
    }//from w w  w .j av a 2 s .  c  o m
    return "/login"; //$NON-NLS-1$
}