List of usage examples for javax.servlet.http HttpSession setAttribute
public void setAttribute(String name, Object value);
From source file:com.silverpeas.servlets.upload.AjaxFileUploadServlet.java
private synchronized void endingToSaveUploadedFile(HttpSession session) { session.setAttribute(SAVING_FILE_FLAG, null); }
From source file:com.cloudbees.demo.beesshop.cart.ShoppingCartRepository.java
@Nonnull public ShoppingCart getCurrentShoppingCart(@Nonnull HttpServletRequest request) { HttpSession session = request.getSession(); ShoppingCart shoppingCart = (ShoppingCart) session.getAttribute(ShoppingCart.class.getName()); if (shoppingCart == null) { shoppingCart = new ShoppingCart(); session.setAttribute(ShoppingCart.class.getName(), shoppingCart); }/*w w w. j av a 2 s . co m*/ return shoppingCart; }
From source file:com.surfs.storage.web.controller.storage.GlobleController.java
@RequestMapping(value = "/switchDataCenter.do") public ModelAndView switchDataCenter(String dataCenterKey, HttpSession session) { Map<String, String> dataCenterMap = getDataCenterMap(); String dataCenterName = dataCenterMap.get(dataCenterKey); session.setAttribute("dataCenterKey", dataCenterKey); session.setAttribute("dataCenterName", dataCenterName); dataCenterMap.remove(dataCenterKey); if (dataCenterMap.size() > 0) session.setAttribute("dataCenterMap", dataCenterMap); return new ModelAndView("redirect:/storage/showGlobleProperties.do"); }
From source file:AES.Controllers.LoginController.java
@RequestMapping(value = "/verify", method = RequestMethod.POST) public String test(@RequestParam Map<String, String> requestParams, // used to get all parameters using a map Model model, // used to add attributes to next/redirected page HttpSession session // used to get current session ) {//from w ww.j a v a 2 s .co m //ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes(); //HttpSession session = attr.getRequest().getSession(); session.setAttribute("test", requestParams.get("password")); model.addAttribute("test", requestParams.get("username")); return "home"; }
From source file:gaia.controller.JoueurController.java
@RequestMapping(value = "/", method = RequestMethod.POST) public String connexion(@ModelAttribute("connexion") Joueur j, HttpSession session) { Joueur user = joueurServ.findByNomAndMotdepasse(j.getNom(), j.getMotdepasse()); if (user != null) { // Le joueur existe session.setAttribute("idUtilConnecte", user.getId()); return "redirect:/gestion_jeu"; }//w w w . j a v a 2 s . com return "redirect:/ajouter_joueur"; }
From source file:org.openmrs.web.controller.encounter.EncounterRoleFormController.java
private void unRetireEncounterRole(EncounterRole encounterRole, EncounterService service, HttpSession session) { service.unretireEncounterRole(encounterRole); session.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "EncounterRole.unretired"); }
From source file:Index.LoginServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww .j av a2s. c om * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { String user, password, errorMessage; if (request.getParameter("user") != null && request.getParameter("password") != null) { user = request.getParameter("user"); password = request.getParameter("password"); if (user.equalsIgnoreCase("") || password.equalsIgnoreCase("")) { errorMessage = "Ingrese todos los datos."; request.setAttribute("error", errorMessage); request.setAttribute("funcionalidad", "Login"); request.getRequestDispatcher("/Login.jsp").forward(request, response); } else { if (user.equals("admin") && password.equals("admin")) { HttpSession session = request.getSession(); session.setAttribute("Admin", user); request.removeAttribute("error"); request.removeAttribute("funcionalidad"); request.getRequestDispatcher("/Index.jsp").forward(request, response); } else { QuickOrderWebService webService = new QuickOrderWebService(); ControllerInterface port = webService.getQuickOrderWebServicePort(); webservice.Cliente usr = port.infoCliente(user); if (usr != null && usr.getNickname() != null) { String encriptMD5 = DigestUtils.md5Hex(password); password = "md5:" + encriptMD5; if (usr.getPassword().equals(password)) { HttpSession session = request.getSession(); session.setAttribute("Usuario", usr); request.removeAttribute("error"); request.removeAttribute("funcionalidad"); request.getRequestDispatcher("/Index.jsp").forward(request, response); } else { errorMessage = "Credenciales invalidas"; request.setAttribute("error", errorMessage); request.setAttribute("funcionalidad", "Login"); request.getRequestDispatcher("/Login.jsp").forward(request, response); } } else { errorMessage = "Credenciales invalidas"; request.setAttribute("error", errorMessage); request.setAttribute("funcionalidad", "Login"); request.getRequestDispatcher("/Login.jsp").forward(request, response); } } } } else { errorMessage = "Error al realizar login."; request.setAttribute("error", errorMessage); request.setAttribute("funcionalidad", "Login"); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/Login.jsp"); dispatcher.forward(request, response); } } catch (Exception ex) { out.println("Error en proceso de login: " + ex.getMessage()); } finally { out.close(); } }
From source file:org.openmrs.module.dictionarysubscribing.web.controller.DictionarySubscribingController.java
@RequestMapping(MODULE_URL + "subscribed") public String subscribed(HttpSession httpSession, ModelMap model) { ImportedPackage importedPackage = getService().getSubscribedDictionary(); if (importedPackage.hasSubscriptionErrors()) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Unable to subscribe to url: " + importedPackage.getSubscriptionStatus()); }// w ww. j a va 2 s .c o m model.addAttribute("locked", getService().isDictionaryLocked()); model.addAttribute("dictionary", getService().getSubscribedDictionary()); model.addAttribute("url", importedPackage.getSubscriptionUrl()); return null; }
From source file:controller.servlet.Upload.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/* ww w . ja v a 2 s . c om*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Obtencin de los ficheros existentes. UploadedFileDaoImpl uFD = new UploadedFileDaoImpl(); HttpSession session = request.getSession(true); session.setAttribute("numberOfCsvFiles", 0); session.setAttribute("numberOfNotCsvFiles", 0); session.setAttribute("error", false); session.setAttribute("mUF", uFD.getFiles()); processRequest(request, response); }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.frontdesk.web.actions.SaveJoinExpAction.java
/** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed.//from ww w.j a v a 2 s .c om * * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception Exception if the application business logic throws * an exception */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes we will need HttpSession session = request.getSession(); if ("request".equals(mapping.getScope())) { request.setAttribute(mapping.getAttribute(), form); } else { session.setAttribute(mapping.getAttribute(), form); } DynaValidatorForm regForm = (DynaValidatorForm) form; return (mapping.findForward("success")); }