Example usage for javax.servlet.http HttpSession setAttribute

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

Introduction

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

Prototype

public void setAttribute(String name, Object value);

Source Link

Document

Binds an object to this session, using the name specified.

Usage

From source file:Controladores.ControladorLogin.java

@RequestMapping("efetua-logoff")
public String logOff(HttpSession sessao) {
    sessao.setAttribute("logado", false);
    return "redirect:index";
}

From source file:de.cuseb.bilderbuch.pdf.PdfController.java

@RequestMapping(value = "/pdf", method = RequestMethod.POST)
public void requestPdf(@RequestBody PdfRequest pdfRequest, HttpSession session) {

    session.setAttribute("pdfRequest", pdfRequest);
}

From source file:game.com.LoginServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (AppConfig.isLive) {
        if (!request.isSecure()) {
            doGet(request, response);/*from  www  .  j  a va 2 s .c  o m*/
            logger.info("!request.isSecure()");
            //                return;
        }
    }
    String username = request.getParameter("username");
    String password = request.getParameter("password");

    if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
        doGet(request, response);
        logger.info("username=" + username + ",password=" + password);
        return;
    }
    HttpSession session = request.getSession();
    session.setAttribute("user", "hihi");
    response.sendRedirect("/");
}

From source file:com.naver.timetable.controller.UserController.java

@RequestMapping(value = "/editUser")
public ModelAndView editUser(HttpServletRequest request, String email) {
    ModelAndView mv = new ModelAndView("userEditForm");
    mv.addObject("user", userBO.getUser(email));

    // ? ?   ? .//from   w  w w. j a va 2s. co  m
    HttpSession session = request.getSession();
    session.setAttribute("targetPage", request.getHeader("Referer"));
    return mv;
}

From source file:mvc.controller.LoginController.java

@RequestMapping("/efetuaLogin")
public String efetuaLogin(Usuario user, HttpSession session) {
    if (dao.validaUsuario(user)) {
        session.setAttribute("usuarioLogado", user);
        session.removeAttribute("msgLoginInvalido");
        return "menuAdm";
    } else {/*from   w  w w .ja v  a 2s. c o m*/
        session.setAttribute("msgLoginInvalido", "O login no foi validado!");
        return "redirect:formLogin";
    }

}

From source file:com.abdin.noorsingles.service.AdminService.java

public void authenticate(String username, String password, HttpSession session) {

    if (isAuthorized(username, password)) {
        session.setAttribute("authenticated", true);
    } else {//  w  ww .j  a  v a2  s . c  om
        session.setAttribute("authenticated", false);
    }
}

From source file:org.openmrs.module.dms.web.controller.main.DeleteUnitController.java

@RequestMapping(method = RequestMethod.POST)
public String onSubmit(Model model, HttpServletRequest request) {
    DmsService dmsService = Context.getService(DmsService.class);
    DmsOpdUnit dmsopdunit = new DmsOpdUnit();
    String select[] = request.getParameterValues("showResultsn");
    if (select != null && select.length != 0) {
        for (int i = 0; i < select.length; i++) {
            Integer unitid = Integer.parseInt(select[i]);
            dmsopdunit = dmsService.getDmsOpd(unitid);
            dmsService.deleteDmsOpdUnit(dmsopdunit);
        }//  ww w.j a v  a2s .  com
    }

    HttpSession httpSession = request.getSession();

    httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "dms.delete.success");
    return "redirect:/module/dms/deleteUnit.form";
}

From source file:be.fedict.eid.applet.beta.AuthenticationServiceBean.java

public void validateCertificateChain(List<X509Certificate> certificateChain) throws SecurityException {
    LOG.debug("validate certificate chain: " + certificateChain);

    HttpServletRequest httpServletRequest;
    try {/*from w w  w. j a  v  a2s . c  o  m*/
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession httpSession = httpServletRequest.getSession();
    httpSession.setAttribute("authenticationCertificateChain", certificateChain);
}

From source file:com.zuoxiaolong.blog.api.component.authorization.AuthorizationFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    String token = request.getHeader("token");
    if (StringUtils.isEmpty(token)) {
        filterChain.doFilter(request, response);
        return;/*  ww w.jav  a2  s.c  o  m*/
    }
    WebUser webUser = webUserService.checkToken(token);
    if (ObjectUtils.isNull(webUser)) {
        filterChain.doFilter(request, response);
        return;
    }
    if (AuthorizationHelper.isTokenExpired(token, webUser.getPassword())) {
        filterChain.doFilter(request, response);
        return;
    }
    HttpSession session = request.getSession(true);
    session.setAttribute("username", webUser.getUsername());
    session.setAttribute("webUserId", webUser.getId());
    filterChain.doFilter(request, response);
}

From source file:fi.arcusys.oulu.web.FormController.java

@ModelAttribute(value = "tasklink")
public String model(@RequestParam String tasklink, @RequestParam String currentPage,
        @RequestParam String numPerPage, @RequestParam String taskType, @RequestParam String keyword,
        @RequestParam String orderType, RenderRequest request) {

    // store parameters in session for returning page from form page
    HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request);
    HttpSession httpSession = httpRequest.getSession();
    httpSession.setAttribute("currentPage", currentPage);
    httpSession.setAttribute("numPerPage", numPerPage);
    httpSession.setAttribute("taskType", taskType);
    httpSession.setAttribute("keyword", keyword);
    httpSession.setAttribute("orderType", orderType);

    return tasklink;
}