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:io.getlime.security.powerauth.rest.api.spring.annotation.PowerAuthWebArgumentResolver.java

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
        NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
    HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest();
    return request.getAttribute(PowerAuth.AUTHENTICATION_OBJECT);
}

From source file:ru.org.linux.csrf.CSRFRequestDataValueProcessor.java

@Override
public Map<String, String> getExtraHiddenFields(HttpServletRequest request) {
    String csrfAttribute = (String) request.getAttribute(CSRF_ATTRIBUTE);

    if (csrfAttribute != null) {
        return ImmutableMap.of(CSRF_INPUT_NAME, csrfAttribute);
    } else {// ww  w.j a  va 2s  .c om
        logger.debug("missing CSRF attribute " + request.getRequestURI());

        return null;
    }
}

From source file:org.bonitasoft.web.designer.controller.WidgetDirectiveLoaderController.java

/**
 * Extract path from a controller mapping. /generator/widgets/pbInput/pbInput.js => /pbInput/pbInput.js
 *//*w w w. ja v a  2  s. c o  m*/
private Path extractPathWithinPattern(final HttpServletRequest request) {
    String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
    String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
    String finalPath = new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
    return widgetRepositoryPath.resolve(finalPath);
}

From source file:de.berlios.jhelpdesk.web.tools.LocaleCustomResolver.java

public Locale resolveLocale(HttpServletRequest request) {
    Locale raLocale = (Locale) request.getAttribute("jhd_locale");
    if (raLocale != null) {
        return raLocale;
    }/*from   ww w  .  j  a  va  2 s .  c  om*/
    HttpSession session = request.getSession();
    User currentUser = (User) session.getAttribute("user");
    if (currentUser != null && currentUser.getUserId() != null) {
        request.setAttribute("jhd_locale", currentUser.getPreferredLocale());
        return currentUser.getPreferredLocale();
    }
    Cookie localeCookie = WebUtils.getCookie(request, "jhd_locale");
    if (localeCookie != null) {
        Locale locale = StringUtils.parseLocaleString(localeCookie.getValue());
        if (locale != null) {
            request.setAttribute("jhd_locale", locale);
            return locale;
        }
    }
    request.setAttribute("jhd_locale", request.getLocale());
    return request.getLocale();
}

From source file:org.wallride.web.support.BlogLanguageLocaleResolver.java

@Override
public Locale resolveLocale(HttpServletRequest request) {
    BlogLanguage blogLanguage = (BlogLanguage) request
            .getAttribute(BlogLanguageMethodArgumentResolver.BLOG_LANGUAGE_ATTRIBUTE);
    if (blogLanguage == null) {
        Blog blog = blogService.getBlogById(Blog.DEFAULT_ID);
        blogLanguage = blog.getLanguage(blog.getDefaultLanguage());
    }//  ww  w .  ja  v a 2 s  .  co m

    return (blogLanguage != null) ? Locale.forLanguageTag(blogLanguage.getLanguage()) : request.getLocale();
}

From source file:com.trenako.web.controllers.ErrorController.java

@RequestMapping(value = "/server-error")
public ModelAndView resolveException(HttpServletRequest request) {
    Exception ex = (Exception) request.getAttribute("javax.servlet.error.exception");
    LogUtils.logException(log, ex);/* w  w w . j a  v  a 2 s  . c o  m*/

    if (isLocalhost(request)) {
        String error = ExceptionUtils.getStackTrace(ex);
        ModelAndView debugView = new ModelAndView("error/debug");
        debugView.addObject("error", error);
        debugView.addObject("request", request);
        return debugView;
    } else {
        return new ModelAndView("error/error");
    }
}

From source file:de.chludwig.websec.saml2sp.controller.Saml2SPSSOController.java

/**
 * Checks if an HTTP request is forwarded from servlet.
 *///from  w w  w . j  a v  a  2  s. c o m
private boolean isForwarded(HttpServletRequest request) {
    return request.getAttribute("javax.servlet.forward.request_uri") != null;
}

From source file:com.ync365.px.web.account.LoginController.java

@RequestMapping(method = RequestMethod.POST)
public String fail(HttpServletRequest request, HttpServletResponse response) {
    String msg = (String) request.getAttribute("shiroLoginFailure");
    if (StringUtils.length(msg) >= 15) {//?????
        request.setAttribute("errorMsg", "???");
    } else {//w  w w  . ja v a 2  s .  c  o  m
        request.setAttribute("errorMsg", msg);
    }
    if (!SecurityUtils.getSubject().isAuthenticated()) {
        response.setStatus(901);
        return "account/login_soft";
    }
    return "redirect:/tohomepage";
}

From source file:ch.sbb.releasetrain.jsfbootadapter.FileDownloadUtil.java

@RequestMapping(value = "/static/**", method = RequestMethod.GET)
public void getFile(HttpServletResponse response, HttpServletRequest request) {
    try {/*from  w w w .  j av a  2  s  . c o m*/

        String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
        PathMatchingResourcePatternResolver res = new PathMatchingResourcePatternResolver();

        Resource template = res.getResource(path);

        if (!template.exists()) {
            log.info("file n/a... " + path);
            return;
        }

        org.apache.commons.io.IOUtils.copy(template.getInputStream(), response.getOutputStream());
        response.flushBuffer();

    } catch (IOException ex) {
        log.info("Error writing file to output stream", ex);
    }
}

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

@Override
protected void noHandlerFound(HttpServletRequest request, HttpServletResponse response) throws Exception {
    if (request.getAttribute(SETHANDLED_FALSE_CALLED) == null) {
        if (reflect.safeInstanceOf(request, "org.eclipse.jetty.server.Request")
                || reflect.safeInstanceOf(request, "org.mortbay.jetty.Request")) {
            reflect.invokeMethod(request, "setHandled", new Object[] { false });
        }/*from  w ww  .  j ava  2  s .c om*/
        request.setAttribute(SETHANDLED_FALSE_CALLED, true);
    }
}