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.owasp.webgoat.controller.Start.java
/** * <p>checkWebSession.</p>// www. j a va2 s . co m * * @param session a {@link javax.servlet.http.HttpSession} object. * @return a boolean. */ public boolean checkWebSession(HttpSession session) { Object o = session.getAttribute(WebSession.SESSION); if (o == null) { logger.error("No valid WebSession object found, has session timed out? [" + session.getId() + "]"); return false; } if (!(o instanceof WebSession)) { logger.error("Invalid WebSession object found, this is probably a bug! [" + o.getClass() + " | " + session.getId() + "]"); return false; } return true; }
From source file:com.mycompany.login.mb.LoginBean.java
public List carregaBombas() { FacesContext context = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession) context.getExternalContext().getSession(false); Usuario usuario = (Usuario) session.getAttribute("usuarioLogado"); Query query = em.createQuery("SELECT numserie FROM Bombas u WHERE u.nomecliente = :nomecliente"); query.setParameter("nomecliente", usuario.getVinculo()); bombasusuario = query.getResultList(); return bombasusuario; }
From source file:de.berlios.jhelpdesk.web.preferences.DisplayListsEditController.java
@RequestMapping(value = "/preferences/displayLists.html", method = RequestMethod.POST) public String processForm(@ModelAttribute("dlPrefs") DisplayListsPreferences dlPreferences, HttpSession session, ModelMap map) {/*from w ww .j a va2 s.co m*/ User currentUser = (User) session.getAttribute("user"); if (isPrefsOwnedByUser(dlPreferences, currentUser)) { dlPreferences.setUser(currentUser); currentUser.setDlPreferences(dlPreferences); this.userPreferencesDAO.save(dlPreferences); session.setAttribute("user", currentUser); map.addAttribute("preferences", dlPreferences); } return "preferences/displayLists"; }
From source file:com.job.portal.manager.JobApplicationsManager.java
public JSONArray getAppliedJobs(HttpServletRequest request) { JSONArray arr = new JSONArray(); JSONObject obj = null;/*from www . jav a2 s . co m*/ JobApplicationsDAO jad = new JobApplicationsDAO(); try { HttpSession sess = request.getSession(false); obj = (JSONObject) sess.getAttribute("user"); if (obj.has("userId")) { arr = jad.getAppliedJobs(obj.getString("userId")); } else { obj.put("msg", "Please log in to continue"); } } catch (Exception e) { LogOut.log.error("In " + new Object() { }.getClass().getEnclosingClass().getName() + "." + new Object() { }.getClass().getEnclosingMethod().getName() + " " + e); } finally { return arr; } }
From source file:com.eftech.wood.controllers.ControllerCartPhone.java
@RequestMapping(value = "/basket", method = RequestMethod.GET) public String cart(HttpSession session) { ShoppingCart cart = (ShoppingCart) session.getAttribute("cart"); if (cart == null) cart = new ShoppingCart(); cart.calculateTotal("0"); // GDP (for example) session.setAttribute("cart", cart); session.setAttribute("page", "basket"); // return "ru_cart"; }
From source file:mx.com.quadrum.contratos.controller.crud.ContactoController.java
@ResponseBody @RequestMapping(value = "editarContacto", method = RequestMethod.POST) public String editarContacto(@Valid @ModelAttribute("contacto") Contacto contacto, BindingResult bindingResult, HttpSession session) { if (session.getAttribute("usuario") == null) { return SESION_CADUCA; }//from ww w . j av a2s .c o m if (bindingResult.hasErrors()) { return ERROR_DATOS; } if (contactoService.existeCorreo(contacto.getMail())) { Contacto c = contactoService.buscarPorCorreo(contacto.getMail()); if (c.getId() != contacto.getId()) { return "Error...#El correo pertencece a otra persona."; } } return contactoService.editar(contacto); }
From source file:controller.UpdateImage.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); HttpSession session = request.getSession(); String manv = session.getAttribute("manv").toString(); if (!ServletFileUpload.isMultipartContent(request)) { out.println("Nothing to upload"); return;/* w ww . ja va2 s. c o m*/ } FileItemFactory itemfactory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(itemfactory); String a = ""; try { List<FileItem> items = upload.parseRequest(request); for (FileItem item : items) { String myfolder = ("asset/Images/nhanvien") + "/"; File uploadDir = new File( "E:/Cng ngh phn m?m/? ?n/1996Shop/ShopOnline/web/asset/Images/nhanvien"); File file = File.createTempFile("img", ".png", uploadDir); item.write(file); a = myfolder + file.getName(); nv.setImage(a); usersDAO.updateImage(a, manv); response.sendRedirect("Profile.jsp?MaNV=" + manv + ""); } } catch (FileUploadException e) { out.println("upload fail"); } catch (Exception ex) { } }
From source file:com.eftech.wood.controllers.ControllerCartPhone.java
@RequestMapping(value = "/updatequantity", method = RequestMethod.GET) public String Minus(@RequestParam(value = "id") int id, @RequestParam(value = "quantity") int quantity, HttpSession session) { ShoppingCart cart = (ShoppingCart) session.getAttribute("cart"); if (cart == null) cart = new ShoppingCart(); // Iphone iphone = iphoneJDBCTemplate.getIphone(id); // cart.update(iphone, "" + quantity); // We do less on 1 position session.setAttribute("cart", cart); return "redirect:basket.htm"; }
From source file:de.berlios.jhelpdesk.web.preferences.PersonalDataEditController.java
private User getUserFromSession(HttpSession session) { try {//from ww w .j av a 2 s . co m return userDAO.getById(((User) session.getAttribute("user")).getUserId()); } catch (DAOException ex) { throw new RuntimeException(ex); } }
From source file:fi.vm.kapa.identification.shibboleth.extauthn.authn.SCSAuthnHandler.java
@Override public X509Certificate getUserCertificate(HttpServletRequest httpRequest) throws CertificateStatusException { X509Certificate certificate = CertificateUtil.getCertificate(httpRequest.getParameter("scs_cert")); if (certificate == null) { throw new CertificateStatusException("No valid X.509 certificates found in request", NO_CERT_FOUND); }/* w w w . j a v a 2s. c o m*/ // Check signature (original data in HTTP session) HttpSession session = httpRequest.getSession(); String data = (String) session.getAttribute("scs_data"); session.removeAttribute("scs_data"); String signature = httpRequest.getParameter("scs_signature"); if (StringUtils.isBlank(data) || StringUtils.isBlank(signature)) { throw new CertificateStatusException("SCS signature or data missing", SCS_SIGNATURE_FAILED); } boolean signatureValid = CertificateUtil.checkSignature(data, signature, certificate); if (!signatureValid) { throw new CertificateStatusException("SCS signature validity check failed", SCS_SIGNATURE_FAILED); } return certificate; }