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.jkcsoft.web.struts.http.controllers.HttpHelper.java

/**
 * allows non-struts web widgets to save struts errors
 *
 * @param request//from  w  ww  . jav  a 2 s .c om
 * @param errors
 * @throws Exception
 */
public static void saveStrutsErrors(HttpServletRequest request, ActionMessages errors) throws Exception {

    // Remove any error messages attribute if none are required
    if ((errors == null) || errors.isEmpty()) {
        request.removeAttribute(Globals.ERROR_KEY);
        return;
    }

    // Save the error messages we need
    request.setAttribute(Globals.ERROR_KEY, errors);

}

From source file:org.opensprout.osaf.web.interceptor.SessionAttributeNameInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    //release/*from w  w w.ja  v a2s .com*/
    request.removeAttribute(SESSION_ATTR_PREFIX);
    super.postHandle(request, response, handler, modelAndView);
}

From source file:org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoRequestControllerFilter.java

/**
 * Releases the {@link Lock} if present in the HttpSession.
 *//*from  w w  w .  ja va2 s  . c o  m*/
public static boolean simpleReleaseSyncOnSession(HttpServletRequest request) {
    HttpSession session = request.getSession(false);
    if (session == null) {
        if (log.isDebugEnabled()) {
            log.debug(doFormatLogMessage(request,
                    "No more HttpSession: can not unlock !, HttpSession must have been invalidated"));
        }
        return false;
    }
    log.debug(
            "Trying to unlock on session " + session.getId() + " on Thread " + Thread.currentThread().getId());

    Lock lock = (Lock) session.getAttribute(SESSION_LOCK_KEY);
    if (lock == null) {
        log.error("Unable to find session lock, HttpSession may have been invalidated");
        return false;
    } else {
        lock.unlock();
        if (request.getAttribute(SYNCED_REQUEST_FLAG) != null) {
            request.removeAttribute(SYNCED_REQUEST_FLAG);
        }
        if (log.isDebugEnabled()) {
            log.debug("session unlocked on Thread ");
        }
        return true;
    }
}

From source file:com.att.ajsc.csilogging.common.CSILoggingUtils.java

static void removeRequestAttribute(HttpServletRequest request) {
    String[] attributes = { CommonNames.CSI_VERSION, CommonNames.CSI_ORIGINAL_VERSION,
            CommonNames.CSI_USER_NAME, CommonNames.CSI_CONVERSATION_ID, CommonNames.CSI_UNIQUE_TXN_ID,
            CommonNames.CSI_TIME_TO_LIVE, CommonNames.CSI_SEQUENCE_NUMBER, CommonNames.CSI_TOTAL_IN_SEQUENCE,
            CommonNames.CSI_ORIGINATOR_ID, CommonNames.CSI_CLIENT_APP, CommonNames.PERF_RECORD,
            CommonNames.AUDIT_RECORD };//from w w w .  j a v  a  2 s . c  om

    for (int i = 0; i < attributes.length; i++) {
        request.removeAttribute(attributes[i]);
    }
}

From source file:uk.ac.ox.oucs.vle.mvc.DoLoginController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    // The login tool doesn't work in tool native mode.
    request.removeAttribute(Tool.NATIVE_URL);
    ActiveTool tool = toolManager.getActiveTool("sakai.login");
    tool.help(request, response, null, "/login");
    return null;/*w w w .j a va 2  s  . co  m*/
}

From source file:org.springframework.cloud.sleuth.instrument.web.TraceHandlerInterceptor.java

private void clearNewSpanCreatedAttribute(HttpServletRequest request) {
    request.removeAttribute(TraceRequestAttributes.NEW_SPAN_REQUEST_ATTR);
}

From source file:org.nuxeo.ecm.platform.ui.web.auth.plugins.AnonymousAuthenticator.java

protected boolean isAnonymousLoginBlocked(HttpServletRequest httpRequest) {
    if (Boolean.TRUE.equals(httpRequest.getAttribute(BLOCK_ANONYMOUS_LOGIN_KEY))) {
        httpRequest.removeAttribute(BLOCK_ANONYMOUS_LOGIN_KEY);
        return true;
    }//  w ww  . j a  v a  2s  . co m

    HttpSession session = httpRequest.getSession(false);
    if (session != null && Boolean.TRUE.equals(session.getAttribute(BLOCK_ANONYMOUS_LOGIN_KEY))) {
        // next logout will clear the session anyway !!
        // session.setAttribute(BLOCK_ANONYMOUS_LOGIN_KEY, false);
        return true;
    }
    return false;
}

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

public void resetStateForOutboundUrl(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_SITE_KEY_FOR_LINK);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_SERVERNAME_FOR_LINK);
    request.removeAttribute(ServerNameToSiteMapper.ATTR_NAME_SITE_KEY_MATCHES);
    request.removeAttribute(VanityUrlMapper.VANITY_KEY);
}

From source file:net.sourceforge.vulcan.web.struts.actions.ManagePreferencesAction.java

public ActionForward save(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    final PreferencesForm form = (PreferencesForm) actionForm;

    request.removeAttribute(Keys.PREFERENCES);
    request.getSession().setAttribute(Keys.PREFERENCES, form.getConfig());

    final Cookie cookie = new Cookie(Keys.PREFERENCES, preferencesStore.convertToString(form.getConfig()));
    cookie.setPath(request.getContextPath());
    cookie.setMaxAge(60 * 60 * 24 * 365);

    response.addCookie(cookie);/*w  ww. j  a  v a2s . c om*/
    return mapping.findForward("dashboard");
}

From source file:com.glaf.mail.web.springmvc.MailStorageController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");
    Map<String, Object> params = RequestUtils.getParameterMap(request);
    String rowId = ParamUtils.getString(params, "storageId");
    MailStorage mailStorage = null;/*from   w w w .  j av  a2 s  . c o m*/
    if (StringUtils.isNotEmpty(rowId)) {
        mailStorage = mailStorageService.getMailStorage(rowId);
        request.setAttribute("mailStorage", mailStorage);
    }

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

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

    return new ModelAndView("/modules/mail/mailStorage/edit", modelMap);
}