List of usage examples for javax.servlet.http HttpSession getAttribute
public Object getAttribute(String name);
null
if no object is bound under the name. From source file:org.katzorke.cage.CageController.java
@RequestMapping("/cage/gvalidate") public boolean gvalidate(HttpSession session, @RequestParam("token") String actualToken) { CaptchaToken expectedToken = (CaptchaToken) session.getAttribute("gcageToken"); System.out.println("Expected: " + expectedToken.token + ", actual=" + actualToken); return expectedToken.token.equals(actualToken); }
From source file:org.katzorke.cage.CageController.java
@RequestMapping("/cage/yvalidate") public boolean yvalidate(HttpSession session, @RequestParam("token") String actualToken) { CaptchaToken expectedToken = (CaptchaToken) session.getAttribute("ycageToken"); System.out.println("Expected: " + expectedToken.token + ", actual=" + actualToken); return expectedToken.token.equals(actualToken); }
From source file:com.nec.nsgui.action.cifs.CifsSetGlobalAction.java
public ActionForward display(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm dynaForm = (DynaValidatorForm) form; int group = NSActionUtil.getCurrentNodeNo(request); HttpSession session = request.getSession(); String domainName = (String) session.getAttribute(CifsActionConst.SESSION_DOMAIN_NAME); String computerName = (String) session.getAttribute(CifsActionConst.SESSION_COMPUTER_NAME); CifsGlobalInfoBean bean = CifsCmdHandler.getGlobalInfo(group, domainName, computerName); bean.setServerString(NSActionUtil.perl2Page(bean.getServerString(), request)); bean.setAlogFile(NSActionUtil.perl2Page(bean.getAlogFile(), request)); String useAccessLog = "no"; if (!bean.getAlogFile().trim().equals("")) { useAccessLog = "yes"; }// w w w .j a v a 2 s.c o m Map globalLoggingItems = new TreeMap(); for (int i = 0; i < LOGGING_ITEMS.length; i++) { globalLoggingItems.put(LOGGING_ITEMS[i], LOGITEM_MSGKEY_PREFIX + LOGGING_ITEMS[i]); } dynaForm.set("info", bean); dynaForm.set("useAccessLog", useAccessLog); session.setAttribute(CifsActionConst.SESSION_GLOBAL_LOGITEM_MAP, globalLoggingItems); session.setAttribute(CifsActionConst.SESSION_NIC_LIST, bean.getAllInterfaces()); session.setAttribute(CifsActionConst.SESSION_NICLABEL_LIST, bean.getAllInterfacesLabel()); return mapping.findForward("display"); }
From source file:gsn.http.AddressingReqHandler.java
public boolean isValid(HttpServletRequest request, HttpServletResponse response) throws IOException { String vsName = request.getParameter("name"); //Added by Behnaz HttpSession session = request.getSession(); User user = (User) session.getAttribute("user"); if (vsName == null || vsName.trim().length() == 0) { response.sendError(WebConstants.MISSING_VSNAME_ERROR, "The virtual sensor name is missing"); return false; }// w ww.ja v a2 s . c om VSensorConfig sensorConfig = Mappings.getVSensorConfig(vsName); if (sensorConfig == null) { response.sendError(WebConstants.ERROR_INVALID_VSNAME, "The specified virtual sensor doesn't exist."); return false; } //Added by Behnaz. if (Main.getContainerConfig().isAcEnabled() == true) { if (user != null) // meaning, that a login session is active, otherwise we couldn't get there if (user.hasReadAccessRight(vsName) == false && user.isAdmin() == false) // ACCESS_DENIED { response.sendError(WebConstants.ACCESS_DENIED, "Access denied to the specified virtual sensor ."); return false; } } return true; }
From source file:com.starr.smartbuilds.controller.AddController.java
@RequestMapping(method = { RequestMethod.GET }) public String getBuilder(Model model, HttpServletRequest req, HttpServletResponse resp) throws IOException, ParseException { HttpSession session = req.getSession(); User user = (User) session.getAttribute("user"); if (user == null) { resp.sendRedirect("./"); } else {/* w w w . jav a2s. c o m*/ model.addAttribute("authMsg", "Hello," + user.getSummonerName() + "!"); model.addAttribute("exitReg", "<a href='./auth/exit'>Exit</a>"); model.addAttribute("createbuild", "<li><a href='./add' style='color: #deff00;'>Create Build</a></li>"); } Build build = new Build(); build.setName("Build name"); model.addAttribute("build", build); List<Category> categories = categoryDAO.listCategories(); model.addAttribute("categories", categories); List<Tag> tags = tagDAO.listTags(); model.addAttribute("tags", tags); List<Champion> champions = championDAO.listChampions(); model.addAttribute("champions", champions); return "add_build"; }
From source file:com.stormpath.tooter.controller.ProfileController.java
@RequestMapping(method = RequestMethod.GET) public String initForm(ModelMap model, HttpSession session) { User user = (User) session.getAttribute("sessionUser"); model.addAttribute("user", user); model.addAttribute("ADMINISTRATOR_URL", administratorGroupURL); model.addAttribute("PREMIUM_URL", premiumGroupURL); return user == null ? "redirect:/login" : "profile"; }
From source file:net.triptech.buildulator.FlashScopeFilter.java
/** * The doFilterInternal method.//from w w w.ja va2 s.com * * @param request the http servlet request * @param response the http servlet response * @param filterChain the filter chain * @throws ServletException the servlet exception * @throws IOException the IO exception */ @Override protected final void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { HttpSession session = request.getSession(false); if (session != null) { Map<?, ?> flash = (Map<?, ?>) session.getAttribute(FlashScope.FLASH_SCOPE_ATTRIBUTE); if (flash != null) { for (Object key : flash.keySet()) { Object value = flash.get(key); Object currentValue = request.getAttribute((String) key); if (currentValue == null) { request.setAttribute((String) key, value); } } session.removeAttribute(FlashScope.FLASH_SCOPE_ATTRIBUTE); } } filterChain.doFilter(request, response); }
From source file:com.bvvy.photo.web.controller.PgerContoller.java
@RequestMapping(value = "/pger", method = RequestMethod.POST) @AuthMethod(role = "ROLE_COMMON") public String add(PgerFormDto pgerFormDto, MultipartFile idCardImg, MultipartFile shopImg, MultipartFile licenseImg, HttpSession session) { User loginUser = (User) session.getAttribute("loginUser"); Pger pger = new Pger(); pger.setUser(loginUser);/*from w ww . j av a 2s. co m*/ pger.setStatus(PgerStatus.REVIEWING.ordinal()); pger.setIdCardImg(saveImage(idCardImg)); pger.setLicenseImg(saveImage(licenseImg)); pger.setShopImg(saveImage(shopImg)); pger.setWorkAddress(pgerFormDto.getWorkAddress()); pger.setLicenseNo(pgerFormDto.getLicenseNo()); pger.setTrueName(pgerFormDto.getTrueName()); pger.setPgerType(pgerFormDto.getPgerType()); pger.setIdCardNo(pgerFormDto.getIdCardNo()); pgerService.add(pger); // return "redirect:/user/" + loginUser.getId() + "/album"; return "front/pger/add"; }
From source file:id.ac.ipb.ilkom.training.controller.OrderController.java
@RequestMapping(value = "/checkout", method = RequestMethod.GET) public String checkout(Model model, HttpSession session) { Customer customer = (Customer) session.getAttribute("customer"); if (customer == null) { return "redirect:/"; }//from www . j a v a 2 s.c o m Order order = (Order) session.getAttribute("cart"); if (order == null) { return "redirect:/"; } orderService.save(order); model.addAttribute("checkout", order); session.setAttribute("cart", null); session.removeAttribute("cart"); return "checkout"; }
From source file:be.fedict.eid.idp.sp.PhotoServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doGet"); response.setContentType("image/jpg"); response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=-1"); // http 1.1 response.setHeader("Pragma", "no-cache, no-store"); // http 1.0 response.setDateHeader("Expires", -1); ServletOutputStream out = response.getOutputStream(); HttpSession session = request.getSession(); byte[] photoData = (byte[]) session.getAttribute(PHOTO_SESSION_ATTRIBUTE); if (null != photoData) { BufferedImage photo = ImageIO.read(new ByteArrayInputStream(photoData)); if (null == photo) { /*//from w w w. j a v a 2 s . c o m * In this case we render a photo containing some error message. */ photo = new BufferedImage(140, 200, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = (Graphics2D) photo.getGraphics(); RenderingHints renderingHints = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); graphics.setRenderingHints(renderingHints); graphics.setColor(Color.WHITE); graphics.fillRect(1, 1, 140 - 1 - 1, 200 - 1 - 1); graphics.setColor(Color.RED); graphics.setFont(new Font("Dialog", Font.BOLD, 20)); graphics.drawString("Photo Error", 0, 200 / 2); graphics.dispose(); ImageIO.write(photo, "jpg", out); } else { out.write(photoData); } } out.close(); }