Example usage for javax.servlet.http HttpServletRequest getSession

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

Introduction

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

Prototype

public HttpSession getSession();

Source Link

Document

Returns the current session associated with this request, or if the request does not have a session, creates one.

Usage

From source file:com.iterzp.momo.service.impl.RSAServiceImpl.java

@Override
@Transactional(readOnly = true)/* ww  w  .j  a v a  2s  . c o  m*/
public void removePrivateKey(HttpServletRequest request) {
    Assert.notNull(request);
    HttpSession session = request.getSession();
    session.removeAttribute(PRIVATE_KEY_ATTRIBUTE_NAME);
}

From source file:com.me.controller.AddBookDetails.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest hsr, HttpServletResponse hsr1)
        throws Exception {

    HttpSession session = hsr.getSession();
    ModelAndView mv = new ModelAndView();
    int val = (Integer.valueOf(hsr.getParameter("noOfBook")));

    session.setAttribute("val", val);

    if (val > 0) {

        mv.setViewName("GetBookDetails");

    }/*w w w  .j a v  a2 s.co m*/

    return mv;
}

From source file:com.ibm.gbs.gbs_cai_web.config.AuthInterceptor.java

@Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse res, Object o) throws Exception {
    HttpSession session = req.getSession();

    if (session.getAttribute("user") == null) {
        res.sendRedirect("/login");
        return false;
    }/*from w w w .  j  a va  2 s . c  o m*/

    return true;
}

From source file:fr.mby.opa.picsimpl.service.BasicProposalManager.java

protected ProposalBranch _getSelectedBranch(final long albumId, final HttpServletRequest request) {
    final ProposalBranch branch = (ProposalBranch) request.getSession()
            .getAttribute(BasicProposalManager.SELECTED_BRANCH_ID + albumId);
    return branch;
}

From source file:ru.org.linux.auth.SecurityFilter.java

private void forWikiManipulation(HttpServletRequest request, HttpServletResponse response) {
    HttpSession session = request.getSession();
    User user = AuthUtil.getCurrentUser();
    if (user != null) {
        user.acegiSecurityHack(response, session);
    }/* w w  w  . j a  v a 2s. co m*/
}

From source file:com.bluexml.side.framework.alfresco.shareLanguagePicker.MyLocalResolver.java

public Locale resolveLocale(HttpServletRequest request) {
    HttpSession session = request.getSession();
    logger.debug("[resolveLocale] ...");
    logger.debug("[resolveLocale] session Id :" + session.getId());
    Locale l = null;/*from   w  w w. jav  a2s.  c om*/

    RequestContext initRequestContext;
    try {
        initRequestContext = RequestContextUtil.initRequestContext(applicationContext, request);
        String languageFromLayoutParam = LanguageSetter.getLanguageFromLayoutParam(request, initRequestContext);
        l = new Locale(languageFromLayoutParam);
    } catch (Exception e) {
        logger.error("oups " + e.getMessage(), e);
        e.printStackTrace();
    }
    logger.debug("[resolveLocale] resolveLocale = " + l);
    if (l == null) {
        l = Locale.getDefault();
        logger.warn("[resolveLocale] back to default (local is null)= " + l);
    }

    setLocale(request, null, l);

    return l;
}

From source file:LocaleSessionServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    HttpSession userSession = request.getSession();
    if (userSession.isNew()) {
        userSession.setAttribute("userLocale", request.getLocale());
    }//from  ww  w.j av a  2 s  .c  o m
}

From source file:controller.EmployeeController.java

@RequestMapping(value = "/employeemanager", method = RequestMethod.GET)
public String employeeManager(HttpServletRequest request) {
    HttpSession session = request.getSession();
    User user = new GeneralUser();
    if (user.checkSession(session)) {
        if (user.getActor(session, "admin")) {
            request.setAttribute("manv", new Employee().autoMNV());
            request.setAttribute("chucvu", new Employee().getPosition());
            request.setAttribute("mnv", new Employee().getMNV());
            return "quanlynhanvien";
        } else {/*from  www. ja v  a  2  s.  c o m*/
            request.setAttribute("message", "Bn khng c quy?n truy cp vo mc va ri!");
            user.logout(request.getSession());
            return "dangnhap";
        }
    } else {
        request.setAttribute("message", "Vui lng ng nhp!");
        return "dangnhap";
    }

}

From source file:be.fedict.eid.applet.service.impl.CleanSessionProtocolStateListener.java

/**
 * Main constructor.//from   w w  w  . j a v a2 s. co m
 * 
 * @param request
 */
public CleanSessionProtocolStateListener(HttpServletRequest request) {
    this.httpSession = request.getSession();
}

From source file:com.br.uepb.controller.IndexController.java

@RequestMapping(value = "/index/sair.html", method = RequestMethod.GET)
public ModelAndView sairGet(HttpServletRequest request) {

    ModelAndView modelAndView = new ModelAndView();
    String login = request.getSession().getAttribute("login").toString();
    GerenciarSessaoBusiness.removeSessao(login);
    modelAndView.setViewName("redirect:/index/index.html");

    return modelAndView;
}