List of usage examples for javax.servlet.http HttpSession setAttribute
public void setAttribute(String name, Object value);
From source file:org.glassmaker.spring.oauth.OAuth2Util.java
public void setUserId(HttpServletRequest request, String userId) { HttpSession session = request.getSession(); session.setAttribute("userId", userId); }
From source file:com.leapfrog.springFramework.Controller.LoginController.java
@RequestMapping(value = "/check/login", method = RequestMethod.POST) public String LoginAdmin(@RequestParam Map<String, String> parVal, HttpServletRequest request) { String username = parVal.get("username"); String password = parVal.get("password"); System.out.println(username + password); User user = dao.checkUsername(username, password); if (user != null && user.getRole().equalsIgnoreCase("ADMIN")) { HttpSession session = request.getSession(true); session.setAttribute("USER", user); session.setAttribute("ROLE", user.getRole()); }/*from w w w .j a v a 2 s . c o m*/ return "redirect:" + "/admin"; }
From source file:com.linecorp.sample.login.core.application.controller.WebController.java
/** * <p>Redirect to LINE Login Page</p> *//*from w w w . j a v a 2 s . c o m*/ @RequestMapping(value = "/gotoauthpage") public String goToAuthPage(HttpSession httpSession) { final String state = CommonUtils.getToken(); httpSession.setAttribute(LINE_WEB_LOGIN_STATE, state); final String url = lineConfig.getLineWebLoginUrl(state); return "redirect:" + url; }
From source file:com.pkrete.locationservice.admin.controller.mvc.EditLanguageController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("language") Language language, BindingResult result) throws Exception { validator.validate(language, result); if (result.hasErrors()) { return new ModelAndView("edit_language", new ModelMap()); }/*from ww w.j a v a 2 s.c om*/ language.setUpdater(getUser(request).getUsername()); /* Save language to DB */ if (!languagesService.update(language)) { throw new Exception("Updating language failed."); } /* Update logged in user */ HttpSession session = request.getSession(); session.removeAttribute("user"); session.setAttribute("user", usersService.getUser(request.getRemoteUser())); /* Return to languages page */ return new ModelAndView( "redirect:languages.htm?select_language=" + request.getParameter("select_language")); }
From source file:com.pkrete.locationservice.admin.controller.mvc.AddLanguageController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("language") Language language, BindingResult result) throws Exception { Owner owner = getOwner(request); language.setOwner(owner);/*from www . j av a2 s .c om*/ validator.validate(language, result); if (result.hasErrors()) { return new ModelAndView("add_language", new ModelMap()); } language.setCreator(getUser(request).getUsername()); /* Save new language to DB */ if (!languagesService.create(language)) { throw new Exception("Creating language failed."); } /* Does user want to create default templates */ if (request.getParameter("templates") != null) { /* Create default templates. */ templatesService.createDefaults(language.getCode(), owner); } /* Update logged in user */ HttpSession session = request.getSession(); session.removeAttribute("user"); session.setAttribute("user", usersService.getUser(request.getRemoteUser())); /* Return to languages page */ return new ModelAndView("redirect:languages.htm"); }
From source file:com.pkrete.locationservice.admin.controller.mvc.LanguageController.java
protected void updateUser(HttpServletRequest request) { HttpSession session = request.getSession(); session.removeAttribute("user"); session.setAttribute("user", usersService.getUser(request.getRemoteUser())); }
From source file:cs425.yogastudio.controller.AdminController.java
@RequestMapping(value = "/addAdmin", method = RequestMethod.POST) public String addAdmin(String firstname, String lastname, String email, String username, String password, Model model, HttpSession session) { Admin newAdmin = new Admin(firstname, lastname, email, username, password); adminService.addAdmin(newAdmin);/*from ww w. j ava 2 s. c o m*/ session.setAttribute("added", newAdmin.getFirstName()); return "redirect:/signUpSuccess"; }
From source file:com.us.servlet.AuthCode.java
protected void service(HttpServletRequest request, HttpServletResponse response) { final CodeAuth bean = AppHelper.CODE_AUTH; int width = NumberUtils.toInt(request.getParameter("width"), bean.getWidth()); int height = NumberUtils.toInt(request.getParameter("height"), bean.getHeight()); int x = width / (bean.getLength() + 1); int codeY = height - 4; int fontHeight = height - 2; BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D graphics = image.createGraphics(); graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); if (StringUtil.hasText(request.getParameter("bgcolor"))) { graphics.setBackground(ColorHelper.hex2RGB(request.getParameter("bgcolor"))); }//from w w w . j a v a 2 s .co m graphics.fillRect(0, 0, width, height); graphics.setFont(new Font(bean.getFont(), Font.BOLD, fontHeight)); graphics.drawRect(0, 0, width - 1, height - 1); // if (bean.isBreakLine()) { for (int i = 0; i < 15; i++) { int x1 = RandomUtils.nextInt(width); int y1 = RandomUtils.nextInt(height); int x2 = RandomUtils.nextInt(12); int y2 = RandomUtils.nextInt(12); graphics.drawLine(x1, y1, x + x2, y1 + y2); } } char[] CHARSET_AREA = null; if (bean.getType().charAt(0) == '1') { CHARSET_AREA = ArrayUtils.addAll(CHARSET_AREA, BIG_LETTERS); } if (bean.getType().charAt(1) == '1') { CHARSET_AREA = ArrayUtils.addAll(CHARSET_AREA, SMALL_LETTER); } if (bean.getType().charAt(2) == '1') { CHARSET_AREA = ArrayUtils.addAll(CHARSET_AREA, NUMBERS); } StringBuilder randomCode = new StringBuilder(); for (int i = 0; i < bean.getLength(); i++) { String rand = String.valueOf(CHARSET_AREA[RandomUtils.nextInt(CHARSET_AREA.length)]); graphics.setColor(ColorHelper.color(RandomUtils.nextInt(255), RandomUtils.nextInt(255), RandomUtils.nextInt(255))); graphics.drawString(rand, (i + 1) * x, codeY); randomCode.append(rand); } HttpSession session = request.getSession(); session.setAttribute(bean.getSessionKey(), randomCode.toString()); // ? response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("image/png"); try { // Servlet? ServletOutputStream sos = response.getOutputStream(); ImageIO.write(image, "png", sos); sos.close(); } catch (Exception e) { e.printStackTrace(); } }
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 ww. ja v a2 s .c o m return mv; }
From source file:edu.ijse.tcd.controller.JobDoneController.java
@RequestMapping(value = "getJobDone", method = RequestMethod.GET) public String getDetail(ModelMap map, HttpServletRequest request) { String jobNumber = request.getParameter("jobnumber"); ArrayList<JobCard> jobCards = jobCardService.getJobCardDetail(jobNumber); JobCard jobCard = new JobCard(); if (jobCards.size() > 0) { jobCard = jobCards.get(0);//from www . j a v a2s.co m } ArrayList<JobDone> jobDones = jobDoneService.getJobDones(); map.addAttribute("jobDoneList", jobDones); map.addAttribute("jobCardList", jobCards); HttpSession hs = request.getSession(); hs.getAttribute("jobCardDone"); hs.setAttribute("jobCardDone", jobCard); map.addAttribute("jobCardDone", jobCard); return "jobDone"; }