Example usage for javax.servlet.http HttpSession removeAttribute

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

Introduction

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

Prototype

public void removeAttribute(String name);

Source Link

Document

Removes the object bound with the specified name from this session.

Usage

From source file:fr.paris.lutece.portal.web.user.AdminLoginJspBean.java

/**
 * Get the admin contact form/*w  w  w . j  av  a2s  .c  om*/
 * @param request The Http request
 * @return The HTML form
 */
public String getFormContact(HttpServletRequest request) {
    HashMap<String, Object> model = new HashMap<String, Object>();

    // Invalidate a previous session
    HttpSession session = request.getSession();

    if (session != null) {
        session.removeAttribute(SESSION_ATTRIBUTE_USER);
    }

    Locale locale = AdminUserService.getLocale(request);

    model.put(MARK_PARAM_VERSION, AppInfo.getVersion());

    HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_ADMIN_FORM_CONTACT, locale, model);

    return template.getHtml();
}

From source file:com.jing.ebike.controller.UserController.java

@RequestMapping("logout")
public ModelAndView logout(HttpSession sess, Model model) {
    sess.removeAttribute("userName");
    sess.removeAttribute("userId");
    sess.removeAttribute("loginUser");
    ModelAndView mv = new ModelAndView();
    mv.setViewName("redirect:/index");
    return mv;/*from   w  ww .j  ava 2s.c  o m*/
}

From source file:fr.paris.lutece.portal.web.user.AdminLoginJspBean.java

/**
 * Returns the view of forgot password form
 *
 * @param request The request/*ww w .j  a  v a  2s.co  m*/
 * @return The HTML form
 */
public String getForgotPassword(HttpServletRequest request) {
    Map<String, Object> model = new HashMap<String, Object>();

    // Invalidate a previous session
    HttpSession session = request.getSession();

    if (session != null) {
        session.removeAttribute(SESSION_ATTRIBUTE_USER);
    }

    Locale locale = AdminUserService.getLocale(request);

    Enumeration<String> enumParams = request.getParameterNames();
    ReferenceList listParams = new ReferenceList();
    String strParamName;

    while (enumParams.hasMoreElements()) {
        strParamName = enumParams.nextElement();

        String strParamValue = request.getParameter(strParamName);
        listParams.addItem(strParamName, strParamValue);
    }

    model.put(MARK_PARAM_VERSION, AppInfo.getVersion());
    model.put(MARK_PARAMS_LIST, listParams);

    HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_ADMIN_FORGOT_PASSWORD, locale, model);

    return template.getHtml();
}

From source file:fr.paris.lutece.portal.web.user.AdminLoginJspBean.java

/**
 * Returns the view of forgot password form
 *
 * @param request The request//from   ww w  .  j  ava2  s  . c  o  m
 * @return The HTML form
 */
public String getForgotLogin(HttpServletRequest request) {
    Map<String, Object> model = new HashMap<String, Object>();

    // Invalidate a previous session
    HttpSession session = request.getSession();

    if (session != null) {
        session.removeAttribute(SESSION_ATTRIBUTE_USER);
    }

    Locale locale = AdminUserService.getLocale(request);

    Enumeration<String> enumParams = request.getParameterNames();
    ReferenceList listParams = new ReferenceList();
    String strParamName;

    while (enumParams.hasMoreElements()) {
        strParamName = enumParams.nextElement();

        String strParamValue = request.getParameter(strParamName);
        listParams.addItem(strParamName, strParamValue);
    }

    model.put(MARK_PARAM_VERSION, AppInfo.getVersion());
    model.put(MARK_PARAMS_LIST, listParams);

    HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_ADMIN_FORGOT_LOGIN, locale, model);

    return template.getHtml();
}

From source file:info.magnolia.cms.gui.dialog.DialogControlImpl.java

public void removeSessionAttribute() {
    String name = this.getConfigValue(SESSION_ATTRIBUTENAME_DIALOGOBJECT);
    HttpServletRequest request = this.getRequest();
    if (request == null) {
        request = this.getTopParent().getRequest();
    }//from  w  w  w. j a  v  a  2s. c om
    try {
        HttpSession httpsession = request.getSession(false);
        if (httpsession != null) {
            httpsession.removeAttribute(name);
        }
    } catch (Exception e) {
        if (log.isDebugEnabled())
            log.debug("removeSessionAttribute() for " + name + " failed because this.request is null"); //$NON-NLS-1$ //$NON-NLS-2$
    }
}

From source file:com.comcast.video.dawg.controller.park.ParkController.java

/**
 * Provides the user latest executed search JSON string extracted from the user session object. After processing the
 * request it removes the latest search condition from session
 *
 * @param session//from  w  ww.  ja v a 2  s .co  m
 *            User session object where last user executed advance search condition is present.
 * @return Latest JSON advanced search condition executed by user, blank JSON object if no latest advanced search
 *         executed by user.
 */
private String returnAndRemoveLatestSearchCondition(HttpSession session) {
    String searchCondition = EMPTY_JSON_OBJECT;
    Object sessionSearchCondtion = session.getAttribute(LATEST_SEARCH_CONDITION_SESSION_ATTRIBUTE_NAME);
    if (null != sessionSearchCondtion) {
        searchCondition = (String) sessionSearchCondtion;
        session.removeAttribute(LATEST_SEARCH_CONDITION_SESSION_ATTRIBUTE_NAME);
    }
    return searchCondition;
}

From source file:com.evolveum.midpoint.web.page.login.PageLogin.java

@Override
protected void onConfigure() {
    super.onConfigure();

    ServletWebRequest req = (ServletWebRequest) RequestCycle.get().getRequest();
    HttpServletRequest httpReq = req.getContainerRequest();
    HttpSession httpSession = httpReq.getSession();

    Exception ex = (Exception) httpSession.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
    if (ex == null) {
        return;/* w w  w  .  j  av a2  s.c  o m*/
    }

    String msg = ex.getMessage();
    if (StringUtils.isEmpty(msg)) {
        msg = "web.security.provider.unavailable";
    }

    msg = getLocalizationService().translate(msg, null, getLocale(), msg);
    error(msg);

    httpSession.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);

    clearBreadcrumbs();
}

From source file:eionet.cr.web.action.CustomSearchActionBean.java

/**
 *
 *//*from w ww . j a  va 2 s  . co  m*/
private void clearSessionAttributes() {
    HttpSession session = getContext().getRequest().getSession();
    session.removeAttribute(RESULT_LIST_SESSION_ATTR_NAME);
    session.removeAttribute(MATCH_COUNT_SESSION_ATTR_NAME);
    session.removeAttribute(PAGINATION_SESSION_ATTR_NAME);
    session.removeAttribute(SELECTED_FILTERS_SESSION_ATTR_NAME);
}

From source file:com.netspective.sparx.security.HttpLoginManager.java

public void logout(HttpServletValueContext vc) {
    vc.getProject().getScrollStates().removeActiveState(vc);

    if (isAllowRememberUserId()) {
        Cookie cookie = new Cookie(getRememberUserIdCookieName(), "");
        cookie.setPath(getRememberPasswordCookiePath(vc));
        cookie.setMaxAge(-1);//  w w w .j av  a2 s . co m
        vc.getHttpResponse().addCookie(cookie);
        cookie = new Cookie(getRememberPasswordCookieName(), "");
        cookie.setPath(getRememberPasswordCookiePath(vc));
        cookie.setMaxAge(-1);
        vc.getHttpResponse().addCookie(cookie);
    }

    final HttpServletRequest req = vc.getHttpRequest();
    final MutableAuthenticatedUser user = (MutableAuthenticatedUser) getAuthenticatedUser(req);
    final HttpSession session = req.getSession();
    if (user != null) {
        registerLogout(vc, user);
        session.removeAttribute(getAuthenticatedUserSessionAttrName());
    }
    session.invalidate();
}

From source file:com.glweb.web.struts.actions.HelloAction.java

/**
 * @see org.apache.struts.action.Action#execute(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse)
 *///  ww  w  .  java 2s  .  c o m
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    HttpSession _session = request.getSession();

    String _action = (String) PropertyUtils.getSimpleProperty(form, "action");

    if (null == _action) {
        return (mapping.getInputForward());
    }

    // Was this transaction cancelled?
    if (isCancelled(request)) {
        if (getLogger().isInfoEnabled()) {
            getLogger().info(" " + mapping.getAttribute() + " - Hello transaction was cancelled");
        }

        removeFormBean(mapping, request);

        _session.removeAttribute(Constants.USER_KEY);

        return (mapping.findForward("/view/hello/cancel"));
    }

    User _user = null;
    String _name = (String) PropertyUtils.getSimpleProperty(form, "name");

    _user = new User();
    _user.setName(_name);

    if (getLogger().isInfoEnabled()) {
        getLogger().info("user = " + _user);
    }

    _session.setAttribute(Constants.USER_KEY, _user);

    return (mapping.findForward("/view/hello/success"));
}