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:mx.com.quadrum.contratos.controller.crud.PermisoController.java
@ResponseBody @RequestMapping(value = "agregarPermiso", method = RequestMethod.POST) public String agregarPermiso(@Valid @ModelAttribute("permiso") Permiso permiso, BindingResult bindingResult, HttpSession session) { if (session.getAttribute("usuario") == null) { return SESION_CADUCA; }/*from w w w .j a v a2 s. c om*/ if (bindingResult.hasErrors()) { return ERROR_DATOS; } return permisoService.agregar(permiso); }
From source file:mx.com.quadrum.contratos.controller.crud.PermisoController.java
@ResponseBody @RequestMapping(value = "editarPermiso", method = RequestMethod.POST) public String editarPermiso(@Valid @ModelAttribute("permiso") Permiso permiso, BindingResult bindingResult, HttpSession session) { if (session.getAttribute("usuario") == null) { return SESION_CADUCA; }// w w w . j a v a 2 s . c o m if (bindingResult.hasErrors()) { return ERROR_DATOS; } return permisoService.editar(permiso); }
From source file:ph.fingra.statisticsweb.controller.LoginLogoutController.java
@RequestMapping(value = "logout", method = RequestMethod.GET) public void logout(HttpSession session) { FingraphUser userDetails = (FingraphUser) session.getAttribute("userLoginInfo"); logger.debug("Welcome logout! {}, {}", session.getId(), userDetails.getUsername()); session.invalidate();//from w w w . j a va 2 s . c o m }
From source file:com.liferay.portal.action.LoginAction.java
public static HashMap getUserCarryAttributes(HttpSession ses) { HashMap result = new HashMap(); Enumeration enu = ses.getAttributeNames(); while (enu.hasMoreElements()) { String name = (String) enu.nextElement(); if (name.startsWith("USER_CARRY")) { result.put(name, ses.getAttribute(name)); }/*from w w w . j ava 2s . c om*/ } return result; }
From source file:com.havoc.hotel.controller.HomeController.java
@RequestMapping(method = RequestMethod.GET, value = "logout") public String Logout(HttpServletRequest req, HttpServletResponse resp) { HttpSession session = req.getSession(false); String checking = (String) session.getAttribute("username"); if (checking == null) { return "redirect:/?logout=false"; } else {/*from w ww.j a v a2s . c om*/ session.invalidate(); return "redirect:/"; } }
From source file:ems.web.controller.other.HireInitController.java
@RequestMapping(value = "/hireApply", method = RequestMethod.GET) public ModelAndView initResumeForm(@RequestParam String comName, HttpSession httpSession) { int memberCode = ((LoginCompleteDTO) httpSession.getAttribute("loginMember")).getCode(); return new ModelAndView("/hire/hireApply").addObject("name", comName) .addObject("academicAbility", resumeServiceImpl.selectAcademicAbility(memberCode)) .addObject("license", resumeServiceImpl.selectLicense(memberCode)) .addObject("career", resumeServiceImpl.selectCareer(memberCode)) .addObject("memberData", resumeServiceImpl.getResumeInitUserData( ((LoginCompleteDTO) httpSession.getAttribute("loginMember")).getId())); }
From source file:org.alliance.rebel.tomcat.web.SampleController.java
@RequestMapping(value = "/getSession/{key}") @ResponseBody//from w w w . j a v a2s . co m public String setSession(@PathVariable("key") String key, HttpSession session) { return (String) session.getAttribute(key); }
From source file:com.aurel.track.prop.LoginBL.java
/** * This method controls entire login procedure. * * @param isInTestMode//ww w. j ava 2 s . c om * @param isMobileApplication * @param username * @param usingContainerBasedAuthentication * @param password * @param forwardUrl * @param springAuthenticated * @param mobileApplicationVersionNo * @param locale * @return */ public static String login(String isInTestMode, boolean isMobileApplication, String username, boolean usingContainerBasedAuthentication, String password, String forwardUrl, boolean springAuthenticated, Integer mobileApplicationVersionNo, Locale _locale) { Boolean ready = (Boolean) ServletActionContext.getServletContext().getAttribute(ApplicationStarter.READY); if (ready == null || !ready.booleanValue()) { return "loading"; } HttpServletRequest request = ServletActionContext.getRequest(); HttpSession httpSession = request.getSession(); String nonce = (String) httpSession.getAttribute("NONCE"); if ("true".equals(isInTestMode)) { nonce = null; // accept clear text passwords } httpSession.setAttribute(ISMOBILEAPP, isMobileApplication); Locale locale = _locale; if (locale == null) { locale = Locale.getDefault(); LOGGER.debug("Requested locale is null. Using default:" + locale.getDisplayName()); } else { LOGGER.debug("Requested locale " + locale.getDisplayName()); } httpSession.setAttribute("localizationJSON", LocalizeJSON.encodeLocalization(locale)); TMotdBean motd = MotdBL.loadMotd(locale.getLanguage()); if (motd == null) { motd = MotdBL.loadMotd("en"); } // if already logged in forward to home page if (SessionUtils.getCurrentUser(httpSession) != null) { String redirectMapEntry = "itemNavigator"; TPersonBean personBean = (TPersonBean) httpSession.getAttribute(Constants.USER_KEY); if (personBean != null && personBean.getHomePage() != null && personBean.getHomePage().trim().length() > 0) { redirectMapEntry = personBean.getHomePage(); } StringBuilder sb = new StringBuilder(); sb.append("{"); JSONUtility.appendBooleanValue(sb, JSONUtility.JSON_FIELDS.SUCCESS, true); sb.append(DATABRACE); JSONUtility.appendStringValue(sb, "jsonURL", redirectMapEntry + DOTACTION, true); sb.append("}"); sb.append("}"); return LoginBL.writeJSONResponse(sb); // The redirect is done by the // client JavaScript } // if Container Based Authentication is enabled and we can get a remote // user we use that one, no more questions asked. However, a local login // always overrules. if ((username == null || "".equals(username) || password == null || "".equals(password)) && (request.getRemoteUser() != null && ApplicationBean.getInstance().getSiteBean().getIsCbaAllowed())) { username = request.getRemoteUser(); usingContainerBasedAuthentication = true; } List<LabelValueBean> errors = new ArrayList<LabelValueBean>(); StringBuilder sb = new StringBuilder(); String redirectMapEntry = ""; sb = LoginBL.createLoginResponseJSON(username, password, nonce, usingContainerBasedAuthentication, springAuthenticated, request, errors, httpSession, forwardUrl, motd, isMobileApplication, locale, mobileApplicationVersionNo, redirectMapEntry); if (errors != null && errors.size() > 0 && usingContainerBasedAuthentication) { return "forwardToLogin"; // could not verify container registered // user with Genji } if (usingContainerBasedAuthentication && !isMobileApplication) { ACCESSLOGGER.info("User was authenticated via container."); if (redirectMapEntry.isEmpty()) return SUCCESS; return redirectMapEntry; } return writeJSONResponse(sb); // The redirect is done by the client // JavaScript }
From source file:com.thoughtworks.go.server.web.TokenManager.java
void create(HttpSession session) { synchronized (session) { if (null == session.getAttribute(TOKEN)) { session.setAttribute(TOKEN, UUID.randomUUID().toString()); }//from w w w. java 2s .c o m } }
From source file:AutoServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { //client browser will request the page every 60 seconds HttpSession session = request.getSession(); Long times = (Long) session.getAttribute("times"); if (times == null) session.setAttribute("times", new Long(0)); long temp = 1; if (times != null) temp = (times.longValue()) + 1;//from w ww. ja v a2s .c o m if (temp < 5) response.addHeader("Refresh", "15"); response.setContentType("text/html"); java.io.PrintWriter out = response.getWriter(); out.println("<html><head><title>Client Refresh</title></head><body>"); //More HTML or dynamic content out.println("You've viewed this page " + temp + " times."); session.setAttribute("times", new Long(temp)); out.println("</body></html>"); }