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:com.virtusa.akura.student.controller.StudentDetailsLoadController.java

/**
 * Sets the primary key of the student to session.
 * //from   ww  w  . j  a v  a  2  s .c  o  m
 * @param request - an instance of HttpServletRequest that contains the request data.
 * @param session - an instance of HttpSession contains the primary key of the student.
 * @return - the name of the view to be redirected.
 * @throws AkuraAppException throws when fails.
 */
@RequestMapping(LOAD_STUDENT)
public String loadData(final HttpServletRequest request, final HttpSession session) throws AkuraAppException {

    String studentIdString = request.getParameter(STUDENT_ID);
    String studentClass = request.getParameter(STUDENT_CLASS);
    session.removeAttribute(SUBJECTS_EXIST);

    if (studentIdString != null) {

        final int studentId = Integer.parseInt(studentIdString);

        if (studentClass != null && !studentClass.equals(AkuraConstant.EMPTY_STRING)) {
            session.setAttribute(STUDENT_CLASS, studentClass);

            List<ClassGrade> classGradeList = commonService.getClassGradeByName(studentClass);

            if (!classGradeList.isEmpty()
                    && studentService.getStudentTermMarksByStudentIdYearClassGrade(studentId,
                            DateUtil.currentYearOnly(), classGradeList.get(0).getClassGradeId()).size() != 0) {

                session.setAttribute(SUBJECTS_EXIST, ON);

            }
        }
        session.setAttribute(STUDENT_ID, studentId);
    }

    return STUDENT_DETAILS;
}

From source file:puma.sp.authentication.controllers.authentication.AccessController.java

@RequestMapping(value = "/ServiceAccessServlet", method = RequestMethod.GET)
public String accessService(@RequestParam(value = "RelayState", defaultValue = "") String relayState,
        @RequestParam(value = "Tenant", defaultValue = "") String tenantIdentifier,
        @RequestParam(value = "Post", defaultValue = "false") Boolean post, ModelMap model,
        HttpSession session) {
    session.setAttribute("Post", post);
    if (session.getAttribute("Authenticated") == null
            || !((Boolean) session.getAttribute("Authenticated")).booleanValue()) {
        session.removeAttribute("Tenant");
        // Ensure relay state is in place
        session.setAttribute("RelayState", relayState);
        this.ensureRelayState(session);
        // Tenant Identifier
        Tenant tenantObject = null;//from w ww  .ja  va 2 s.  co m
        if (tenantIdentifier == null || tenantIdentifier.isEmpty()) {
            session.setAttribute("FlowRedirectionElement", new FlowDirecter("/SubmitWAYF"));
            return "redirect:/";
        } else {
            tenantObject = this.tenantService.findOne(Long.parseLong(tenantIdentifier));
            if (tenantObject == null) {
                logger.log(Level.WARNING, "Could not find tenant with identifier " + tenantIdentifier);
                MessageManager.getInstance().addMessage(session, "info",
                        "Could not find any tenant with identifier " + tenantIdentifier);
                session.setAttribute("FlowRedirectionElement", new FlowDirecter("/SubmitWAYF"));
                return "redirect:/";
            }
        }
        session.setAttribute("Tenant", tenantObject);
        // Redirect to next flow element
        return "redirect:/AuthenticationRequestServlet";
    } else {
        // Subject is already authenticated
        if (relayState != null && !relayState.isEmpty())
            session.setAttribute("RelayState", relayState);
        return "redirect:/AuthenticationResponseServlet";
    }
}

From source file:com.xhm.longxin.qth.web.user.module.action.UserAction.java

public void doLogout(HttpSession session, Navigator nav, ParameterParser params) throws Exception {

    session.removeAttribute(UserConstant.QTH_USER_SESSION_KEY);

    redirectToReturnPage(nav, params);//from w ww . jav  a2s.  c  om
}

From source file:org.openmrs.module.conceptsearch.web.controller.AdvancedSearchFormController.java

@RequestMapping(value = "/module/conceptsearch/advancedSearch", method = RequestMethod.GET)
public void showAdvancedSearch(ModelMap model, WebRequest request, HttpSession session) {

    //reset all session objects used by this controller
    session.removeAttribute("searchResult");
    session.removeAttribute("sortResults");
    session.removeAttribute("conceptSearch");
    session.removeAttribute("historyQuery");
}

From source file:de.micromata.genome.gwiki.auth.GWikiSessionAttributesUserAuthentification.java

@Override
public void logout(GWikiContext ctx) {
    HttpSession session = ctx.getSession(true);
    clearAuthenticationCookie(ctx, null);
    session.removeAttribute(GWIKI_SESSION_ATTRIBUTE);
    GWikiUserServeElementFilterEvent.setUser(null);
}

From source file:org.mitre.openid.connect.web.AuthenticationTimeStamper.java

/**
 * Set the timestamp on the session to mark when the authentication happened,
 * useful for calculating authentication age. This gets stored in the sesion
 * and can get pulled out by other components.
 *///from ww  w.j a v  a 2  s. co  m
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {

    Date authTimestamp = new Date();

    HttpSession session = request.getSession();

    session.setAttribute(AUTH_TIMESTAMP, authTimestamp);

    if (session.getAttribute(AuthorizationRequestFilter.PROMPT_REQUESTED) != null) {
        session.setAttribute(AuthorizationRequestFilter.PROMPTED, Boolean.TRUE);
        session.removeAttribute(AuthorizationRequestFilter.PROMPT_REQUESTED);
    }

    logger.info("Successful Authentication of " + authentication.getName() + " at " + authTimestamp.toString());

    super.onAuthenticationSuccess(request, response, authentication);

}

From source file:edu.vt.middleware.ldap.servlets.session.DefaultSessionManager.java

/**
 * This performs any actions necessary to logout the suppled session.
 *
 * @param  session  <code>HttpSession</code>
 *
 * @throws  ServletException  if an error occurs cleaning up the session
 *//* w  w w .ja  v  a2  s .  c o  m*/
public void logout(final HttpSession session) throws ServletException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Begin logout method");
    }
    if (this.sessionId != null) {
        final String user = (String) session.getAttribute(this.sessionId);
        session.removeAttribute(this.sessionId);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Removed session attribute " + this.sessionId + " for " + user);
        }
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Could not remove session attribute, value is null");
        }
    }
    if (this.invalidateSession) {
        session.invalidate();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Session invalidated");
        }
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Session was not invalidated");
        }
    }
}

From source file:de.itsvs.cwtrpc.security.DefaultRpcHttpSessionStrategy.java

protected void clearSession(HttpServletRequest request, HttpServletResponse response, HttpSession session)
        throws IOException, ServletException {
    for (@SuppressWarnings("unchecked")
    Enumeration<String> names = session.getAttributeNames(); names.hasMoreElements();) {
        session.removeAttribute(names.nextElement());
    }/*from w w w .j a v  a  2  s .  c o m*/
}

From source file:com.baomidou.framework.aop.ResubmitAspect.java

/**
 * <p>//from  w w  w  . jav  a  2 s.  c om
 * ?? token
 * </p>
 * <p>
 * ????token<br>
 * ????
 * </p>
 */
public void validation(ProceedingJoinPoint joinPoint, HttpServletRequest request, HttpSession session,
        String tokenFlag) throws Throwable {
    Object sessionFlag = session.getAttribute(tokenFlag);
    Object requestFlag = request.getParameter(PARAM_TOKEN);
    if (sessionFlag != null && sessionFlag.equals(requestFlag)) {
        session.removeAttribute(tokenFlag);
        joinPoint.proceed();
    }
}

From source file:controllers.LoginController.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request/*from   w ww  .  ja v a  2  s .  c o  m*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    User user = (User) request.getAttribute("user");
    if (user != null) {
        // User has been already registered
        response.sendRedirect(request.getContextPath() + "/home");
    } else {
        // Remove user's session
        HttpSession session = request.getSession(false);
        String error = null;
        if (session != null && (error = (String) session.getAttribute("error")) != null) {
            request.setAttribute("error", error);
            session.removeAttribute("error");
        }
        RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
        rd.forward(request, response);
    }
}