Example usage for javax.servlet.http HttpServletRequest removeAttribute

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

Introduction

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

Prototype

public void removeAttribute(String name);

Source Link

Document

Removes an attribute from this request.

Usage

From source file:org.apache.sling.tracer.internal.TracerLogServlet.java

@Override
public void endRecording(HttpServletRequest httpRequest, Recording recording) {
    if (recording instanceof JSONRecording) {
        JSONRecording r = (JSONRecording) recording;
        r.done();//w w  w  . ja  v a  2s. c om
        cache.put(r.getRequestId(), r);
    }
    httpRequest.removeAttribute(ATTR_RECORDING);
}

From source file:com.opencnc.controllers.RolController.java

/**
 * *****************************************************************************
 * Crea Rol.//from  w w  w. ja va  2  s . c  o m
 * *****************************************************************************
 * @param request
 * @param response
 * @return
 * @throws Exception 
 */
@RequestMapping("/rol/crear")
public ModelAndView crear(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession sess = request.getSession();
    if (sess != null) {
        Rol r = new Rol();

        ModelAndView m = new ModelAndView("/rol/crear");
        m.addObject("rol", r);

        return m;
    } else {
        request.removeAttribute("usuario");
        return new ModelAndView("redirect:/usuario/login.htm");
    }

}

From source file:org.jahia.services.seo.urlrewrite.UrlRewriteService.java

private void resetState(HttpServletRequest request) {
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_CMS_TOKEN);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_DEFAULT_LANG);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_DEFAULT_LANG_MATCHES);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_LANG_TOKEN);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_ADD_CMS_PREFIX);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_SITE_KEY);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_SITE_KEY_FOR_LINK);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_SERVERNAME_FOR_LINK);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_SITE_KEY_MATCHES);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_SKIP_INBOUND_SEO_RULES);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_VANITY_LANG);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_VANITY_PATH);
}

From source file:com.octo.captcha.j2ee.servlet.ImageCaptchaFilter.java

/**
 * Remove captcha filter specific parameters from a request
 * @param theRequest the request/*from w  ww  . j av  a2  s. co m*/
 */
private void removeParametersFromRequest(HttpServletRequest theRequest) {
    theRequest.removeAttribute(CAPTCHA_RESPONSE_PARAMETER_NAME_PARAMETER);
    theRequest.removeAttribute(CAPTCHA_ID_PARAMETER_NAME_PARAMETER);
}

From source file:com.glaf.oa.borrow.web.springmvc.BorrowApproveController.java

@RequestMapping("/approve")
public ModelAndView approve(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");

    Long borrowid = RequestUtils.getLong(request, "borrowids");
    Borrow borrow = borrowService.getBorrow(borrowid);
    List<Borrowmoney> moneylist = borrowmoneyService.getBorrowmoneyByParentId(borrowid);
    List<Borrowadderss> addresslist = borrowadderssService.getBorrowadderssByParentId(borrowid);
    Double totelPrice = 0D;/*  w w  w . j av  a  2  s.co  m*/
    for (Borrowmoney borrowmoney : moneylist) {
        totelPrice += borrowmoney.getFeesum();
    }
    request.setAttribute("addresslist", addresslist);
    request.setAttribute("moneylist", moneylist);
    request.setAttribute("totelPrice", totelPrice);
    request.setAttribute("borrow", borrow);
    JSONObject rowJSON = borrow.toJsonObject();
    request.setAttribute("x_json", rowJSON.toJSONString());
    return new ModelAndView("/oa/borrow/approve_edit", modelMap);
}

From source file:com.glaf.oa.assessinfo.web.springmvc.AssessinfoController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");
    Assessinfo assessinfo = assessinfoService.getAssessinfo(RequestUtils.getLong(request, "indexid"));
    if (assessinfo != null) {
        request.setAttribute("assessinfo", assessinfo);
        JSONObject rowJSON = assessinfo.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
    }/*from   ww w . j a  v a2s .  c  om*/

    boolean canUpdate = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {

    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (assessinfo != null) {
            canUpdate = true;
        }
    }

    request.setAttribute("canUpdate", canUpdate);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = ViewProperties.getString("assessinfo.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/assessinfo/assessinfoEdit", modelMap);
}

From source file:org.xwiki.portlet.controller.DispatchFilter.java

/**
 * Filters an action request./*from w w  w  . j  a  v  a  2 s. co m*/
 * 
 * @param request the request object
 * @param response the response object
 * @param chain the filter chain
 * @throws IOException if writing the response fails
 * @throws ServletException if processing the request fails
 */
private void doAction(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    DispatchedRequest requestWrapper;
    String redirectURL = (String) request.getAttribute(DispatchPortlet.ATTRIBUTE_REDIRECT_URL);
    if (redirectURL != null) {
        request.removeAttribute(DispatchPortlet.ATTRIBUTE_REDIRECT_URL);
        requestWrapper = new DispatchedRequest(request, redirectURL);
    } else {
        // NOTE: Exposing the initial query string parameters on both action and render portlet requests can have
        // unexpected side effects if the action and render portlet requests share the same client request. For the
        // moment we expose the parameters only on action request.
        requestWrapper = new DispatchedRequest(request, true);
    }

    DispatchedActionResponse responseWrapper = new DispatchedActionResponse(response);
    chain.doFilter(requestWrapper, responseWrapper);
    ResponseData responseData = responseWrapper.getResponseData();
    // Transform the redirect URL to be able to use it with a request dispatcher.
    // We pass the request wrapper because we need the request URL for the transformation.
    responseData.sendRedirect(getDispatchURL(responseData.getRedirect(), requestWrapper));
    request.setAttribute(DispatchPortlet.ATTRIBUTE_RESPONSE_DATA, responseData);
}

From source file:org.jasig.ssp.service.impl.UPortalPersonAttributesService.java

@SuppressWarnings("unchecked")
@Override//from   w w  w.jav a 2 s.  co  m
public PersonAttributesResult getAttributes(final String username) throws ObjectNotFoundException {

    LOGGER.debug("Fetching attributes for user '{}'", username);

    final Map<String, String[]> params = new HashMap<String, String[]>();
    params.put(PARAM_USERNAME, new String[] { username });

    final CrossContextRestApiInvoker rest = new PatchedSimpleCrossContextRestApiInvoker();
    final HttpServletRequest req = requestForCrossContextGet();
    final HttpServletResponse res = responseForCrossContextGet();
    final Object origWebAsyncManager = req.getAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE);
    req.removeAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE);

    RestResponse rr;
    try {
        rr = rest.invoke(req, res, REST_URI_PERSON, params);
    } finally {
        req.setAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE, origWebAsyncManager);
    }

    final ObjectMapper mapper = new ObjectMapper();
    Map<String, Map<String, Map<String, List<String>>>> value = null;
    try {
        value = mapper.readValue(rr.getWriterOutput(), Map.class);
    } catch (final Exception e) {
        final String msg = "Failed to access attributes for the specified person:  " + username;
        throw new UPortalSecurityException(msg, e);
    }

    final Map<String, Map<String, List<String>>> person = value.get(PERSON_KEY);
    if (person == null) {
        // No match...
        throw new ObjectNotFoundException("The specified person is unrecognized", username);
    }
    final Map<String, List<String>> rslt = person.get(ATTRIBUTES_KEY);
    if (rslt == null) {
        throw new ObjectNotFoundException("No attributes are available for the specified person", username);
    }

    LOGGER.debug("Retrieved the following attributes for user {}:  {}", username, rslt.toString());

    return convertAttributes(rslt);
}

From source file:org.jasig.ssp.service.impl.UPortalPersonAttributesService.java

@SuppressWarnings("unchecked")
@Override/*w  w  w. j a v  a  2s. c om*/
public List<Map<String, Object>> searchForUsers(final Map<String, String> query) {

    LOGGER.debug("Searching for users with query terms '{}'", query);

    // Assemble searchTerms[] in expected way
    final List<String> searchTerms = new ArrayList<String>();
    final Map<String, String[]> params = new HashMap<String, String[]>();
    for (final Map.Entry<String, String> y : query.entrySet()) {
        searchTerms.add(y.getKey());
        params.put(y.getKey(), new String[] { y.getValue() });
    }

    // Build the URL
    final StringBuilder bld = new StringBuilder(REST_URI_SEARCH_PREFIX);
    for (final String key : params.keySet()) {
        bld.append("&{").append(key).append("}");
    }
    final String url = bld.toString();

    LOGGER.debug("Invoking REST enpoint with URL '{}'", url);

    // Add serchTerms[] to the params
    params.put(PARAM_SEARCH_TERMS, searchTerms.toArray(new String[0]));

    final CrossContextRestApiInvoker rest = new PatchedSimpleCrossContextRestApiInvoker();
    final HttpServletRequest req = requestForCrossContextGet();
    final HttpServletResponse res = responseForCrossContextGet();
    final Object origWebAsyncManager = req.getAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE);
    req.removeAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE);

    RestResponse rr;
    try {
        rr = rest.invoke(req, res, url, params);
    } finally {
        req.setAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE, origWebAsyncManager);
    }

    final ObjectMapper mapper = new ObjectMapper();
    Map<String, List<Map<String, Object>>> value = null;
    try {
        value = mapper.readValue(rr.getWriterOutput(), Map.class);
    } catch (final Exception e) {
        final String msg = "Failed to search for users with the specified query:  " + query;
        throw new PersonAttributesSearchException(msg, e);
    }

    final List<Map<String, Object>> rslt = value.get(PEOPLE_KEY);
    if (rslt == null) {
        // Odd... should at least be an empty list
        final String msg = "Search for users returned no list for the specified query:  " + query;
        throw new PersonAttributesSearchException(msg);
    }

    LOGGER.debug("Retrieved the following people for query {}:  {}", query, rslt);

    return rslt;

}

From source file:org.jahia.services.render.customfilter.WorkInProgressPreviewFilter.java

@Override
public String execute(String previousOut, RenderContext renderContext, Resource resource, RenderChain chain)
        throws Exception {
    final HttpServletRequest request = renderContext.getRequest();
    String attrName = "WIP_" + resource.toString();
    Boolean wipResource = (Boolean) request.getAttribute(attrName);

    if (wipResource != null) {
        //            if (!isPublished(resource.getNode())) {
        //                return "";
        //            }
        request.removeAttribute(attrName);
        renderContext.setWorkspace("default");
        List<String> wipNodes = (List<String>) request.getAttribute("WIP_nodes");
        if (wipNodes != null) {
            if (wipNodes.remove(resource.getNode().getPath())) {
                if (wipNodes.isEmpty()) {
                    request.removeAttribute("WIP_nodes");
                } else {
                    chain.pushAttribute(request, "WIP_nodes", wipNodes);
                }/*from w w  w  .  j av a 2s.  c om*/
            }
        }
        JCRSessionWrapper s = JCRSessionFactory.getInstance().getCurrentUserSession("default",
                resource.getNode().getSession().getLocale(),
                resource.getNode().getSession().getFallbackLocale());

        JCRNodeWrapper n = s.getNode(resource.getNode().getPath());

        resource.setNode(n);
        renderContext.getMainResource().setNode(s.getNode(renderContext.getMainResource().getNode().getPath()));
        String out = removeCacheTags(previousOut);
        return out;

    }
    return previousOut;
}