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.stratelia.silverpeas.pdcPeas.servlets.PdcSearchRequestRouterHelper.java

/**
 * put in the request the primary axis and eventually the secondary axis accroding to search
 * context//  w  w  w  .j  a  va 2 s.c o  m
 *
 * @param pdcSC
 * @param request
 * @throws Exception
 */
public static void setContext(PdcSearchSessionController pdcSC, HttpServletRequest request) throws Exception {
    SilverTrace.info("pdcPeas", "PdcPeasRequestRouterHelper.setContext()", "root.MSG_GEN_ENTER_METHOD");

    // on retire du searchcontext tous les criteres qui ne sont pas dans
    // l'espace choisi par l'utilisateur.
    // Dans ce cas, on retire de la list de searchContext, le critere de
    // recherche.
    SearchContext searchContext = pdcSC.getSearchContext();
    @SuppressWarnings("unchecked")
    List<SearchAxis> primaryAxis = (List<SearchAxis>) request.getAttribute("ShowPrimaryAxis");
    @SuppressWarnings("unchecked")
    List<SearchAxis> secondaryAxis = (List<SearchAxis>) request.getAttribute("ShowSecondaryAxis");
    boolean isExistInPrimaryAxis = false;
    boolean isExistInSecondaryAxis = false;
    SearchAxis sa = null;

    List<SearchCriteria> c = searchContext.getCriterias();
    Axis axis = null;
    int searchAxisId;
    String searchValue = "";
    String treeId = "";
    List<List<Value>> pathCriteria = new ArrayList<List<Value>>(c.size());
    if (!c.isEmpty()) {
        for (SearchCriteria sc : c) {
            searchAxisId = sc.getAxisId();
            if (primaryAxis != null) {
                // on parcourt la liste des axes primaires
                // si l'on trouve un axisId de searchCriteria = axisId de l'axe
                // primaire alors on le laisse
                // dans le searchCriteria sinon on le supprime
                for (int j = 0; j < primaryAxis.size(); j++) {
                    sa = primaryAxis.get(j);
                    if (searchAxisId == sa.getAxisId()) {
                        isExistInPrimaryAxis = true;
                        break;
                    }
                }

            }
            if ((!isExistInPrimaryAxis) && (secondaryAxis != null)) {
                // on parcourt la liste des axes secondaires
                // si l'on trouve un axisId de searchCriteria = axisId de l'axe
                // secondaire alors on l'enleve
                for (int j = 0; j < secondaryAxis.size(); j++) {
                    sa = secondaryAxis.get(j);
                    if (searchAxisId == sa.getAxisId()) {
                        isExistInSecondaryAxis = true;
                        break;
                    }
                }
            }

            if (isExistInSecondaryAxis || isExistInPrimaryAxis) {
                searchValue = getLastValueOf(sc.getValue());
                // on creait un axis
                axis = pdcSC.getAxisDetail(String.valueOf(searchAxisId));
                treeId = String.valueOf(axis.getAxisHeader().getRootId());
                List<Value> fullPath = pdcSC.getFullPath(searchValue, treeId);
                pathCriteria.add(fullPath);
            }
        }
    }
    request.setAttribute("PathCriteria", pathCriteria);
    // on ajoute le contexte de recherche
    request.setAttribute("SearchContext", searchContext);
    SilverTrace.info("pdcPeas", "PdcPeasRequestRouterHelper.setContext()", "root.MSG_GEN_EXIT_METHOD");
}

From source file:org.dspace.webmvc.theme.RequestThemeResolver.java

@Override
public String resolveThemeName(HttpServletRequest httpServletRequest) {
    if (httpServletRequest.getAttribute(RequestThemeResolver.CURRENT_THEME) != null) {
        return (String) httpServletRequest.getAttribute(RequestThemeResolver.CURRENT_THEME);
    }/*from   w  ww .  j  av a 2s. c  om*/

    return getDefaultThemeName();
}

From source file:fi.helsinki.opintoni.config.locale.AngularCookieLocaleResolver.java

private void parseLocaleCookieIfNecessary(HttpServletRequest request) {
    if (request.getAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME) == null) {

        Locale locale = Optional.ofNullable(WebUtils.getCookie(request, getCookieName())).map(Cookie::getValue)
                .map(value -> StringUtils.replace(value, "%22", "")).map(StringUtils::parseLocaleString)
                .orElse(determineDefaultLocale(request));

        request.setAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME, locale);
    }//from w  w w . ja  va 2  s .c o m
}

From source file:com.acc.storefront.interceptors.BeforeViewHandlerInterceptor.java

protected boolean isIncludeRequest(final HttpServletRequest request) {
    return request.getAttribute("javax.servlet.include.request_uri") != null;
}

From source file:com.vdenotaris.spring.boot.security.saml.web.contollers.SSOController.java

private boolean isForwarded(HttpServletRequest request) {
    if (request.getAttribute("javax.servlet.forward.request_uri") == null)
        return false;
    else//from   w w  w  . j  a va  2  s.  c o  m
        return true;
}

From source file:springku.HelloController.java

@RequestMapping(value = "/ambiltanggal/**", method = RequestMethod.GET)
public String belajar1(ModelMap map, HttpServletRequest request) {
    String data = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
    String[] pecah = data.split("/");
    map.addAttribute("nama", pecah[2]);
    return "learning";
}

From source file:com.ctc.storefront.web.mvc.AcceleratorUrlPathHelper.java

@Override
public String getContextPath(final HttpServletRequest request) {
    final Object urlEncodingAttributes = request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
    return StringUtils.remove(super.getContextPath(request),
            urlEncodingAttributes != null ? urlEncodingAttributes.toString() : "");
}

From source file:com.acc.storefront.web.mvc.AcceleratorUrlPathHelper.java

@Override
public String getContextPath(final HttpServletRequest request) {
    final Object urlEncodingAttributes = request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
    return StringUtils.remove(super.getContextPath(request),
            (urlEncodingAttributes != null) ? urlEncodingAttributes.toString() : "");
}

From source file:org.ng200.openolympus.controller.PartialsController.java

@RequestMapping("/partials/**")
String getMapping(final HttpServletRequest request) {
    final String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
    final String bestMatchPattern = (String) request
            .getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);

    final AntPathMatcher apm = new AntPathMatcher();
    final String finalPath = apm.extractPathWithinPattern(bestMatchPattern, path);

    return "partials/" + finalPath + "::content";

}

From source file:it.infn.mw.iam.core.web.IamErrorController.java

private int getErrorCode(HttpServletRequest httpRequest) {
    return (Integer) httpRequest.getAttribute("javax.servlet.error.status_code");
}