List of usage examples for javax.servlet.http HttpSession removeAttribute
public void removeAttribute(String name);
From source file:gov.nih.nci.cananolab.restful.core.BaseAnnotationBO.java
protected void checkOpenAccessForm(HttpServletRequest request) throws Exception { String dispatch = request.getParameter("dispatch"); String browserDispatch = getBrowserDispatch(request); HttpSession session = request.getSession(); Boolean accessValid = true;//from w w w. j a va 2 s .c om if (session.getAttribute("accessValid") != null) { accessValid = (Boolean) session.getAttribute("accessValid"); } Boolean openAccess = false; if (dispatch.equals("input") && browserDispatch.equals("saveAccess") || !accessValid) { openAccess = true; } session.setAttribute("openAccess", openAccess); session.removeAttribute("accessValid"); // in case of validation error still show access label correctly. request.setAttribute("onloadJavascript", "toggleAccessNameLabel()"); }
From source file:gov.nih.nci.cananolab.restful.core.BaseAnnotationBO.java
public void checkOpenAccessForm(PublicationForm form, HttpServletRequest request) { String dispatch = form.getDispatch(); String browserDispatch = getBrowserDispatch(request); HttpSession session = request.getSession(); Boolean accessValid = true;//from w ww . j a v a 2s . c om if (session.getAttribute("accessValid") != null) { accessValid = (Boolean) session.getAttribute("accessValid"); } Boolean openAccess = false; if (dispatch.equals("input") && browserDispatch.equals("saveAccess") || !accessValid) { openAccess = true; } session.setAttribute("openAccess", openAccess); session.removeAttribute("accessValid"); // in case of validation error still show access label correctly. request.setAttribute("onloadJavascript", "toggleAccessNameLabel()"); }
From source file:Controladores.ControladorLogin.java
@RequestMapping("efetua-login") public ModelAndView efetuaLogin(String usuario, String senha, boolean ckSalvaLogin, HttpSession sessao, HttpServletResponse response) {//from ww w .j a v a 2s. c om ModelAndView mv; Funcionario f = DAO.Model.FuncionarioDAO.autenticacaoLogin(usuario, senha); if (f != null) { if (ckSalvaLogin) { Cookie c = new Cookie("loginCookie", usuario); c.setMaxAge(60); // em segundos response.addCookie(c); c = new Cookie("senhaCookie", senha); c.setMaxAge(60); // em segundos response.addCookie(c); } sessao.setAttribute("logado", true); sessao.setAttribute("funcionario", f); if (sessao.getAttribute("endereco") == null) { mv = new ModelAndView("redirect:index"); } else { String endereco = sessao.getAttribute("endereco").toString(); endereco = endereco.substring(endereco.lastIndexOf("/") + 1); mv = new ModelAndView("redirect:" + endereco); } sessao.removeAttribute("endereco"); } else { sessao.setAttribute("logado", false); mv = new ModelAndView("redirect:exibe-login"); } return mv; }
From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java
public String loadSearchResult(BaseDBForm baseDBForm) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logDB.isDebugEnabled()) logDB.debug("||" + baseDBForm.getFormName() + "|loadSearchResult|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }/*from w w w .j a v a 2 s .c om*/ if (session.getAttribute(DisplayConstants.CREATE_WORKFLOW) != null) { //session.removeAttribute(DisplayConstants.CREATE_WORKFLOW); session.removeAttribute(DisplayConstants.SEARCH_RESULT); session.removeAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT); return ForwardConstants.LOAD_HOME_SUCCESS; } else { if (session.getAttribute(DisplayConstants.SEARCH_RESULT) == null && session.getAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT) != null) { session.setAttribute(DisplayConstants.SEARCH_RESULT, session.getAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT)); //session.removeAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT); } } if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|loadSearchResult|Success|Loading the Search Result Page||"); return ForwardConstants.LOAD_SEARCH_RESULT_SUCCESS; }
From source file:dicky.controlleruser.CartController.java
@RequestMapping(value = "checkout", method = RequestMethod.GET) public String checkout(HttpSession session, ModelMap modelMap) { modelMap.put("title", "Pembelian Barang"); if (session.getAttribute("username") == null) { modelMap.put("message", "Anda harus mengisi terlebih dahulu data belanjaan"); return "account.myaccount"; } else {/* w w w .ja va 2 s . co m*/ Orders orders = new Orders(); orders.setAccount(accountService.find(session.getAttribute("username").toString())); orders.setTanggal(new Date()); Orders newOrders = ordersService.create(orders); List<Item> cart = (List<Item>) session.getAttribute("cart"); for (Item item : cart) { OrdersDetail ordersDetail = new OrdersDetail(); ordersDetail.setId(new OrdersDetailId(newOrders.getIdOrders(), item.getProduct().getIdProduct())); ordersDetail.setPrice(item.getProduct().getPrice()); ordersDetail.setQuantity(item.getQuantity()); ordersDetailService.create(ordersDetail); } session.removeAttribute("username"); cart.clear(); return "cart.thanks"; } }
From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java
public String loadAdd(BaseDBForm baseDBForm) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logDB.isDebugEnabled()) logDB.debug("||" + baseDBForm.getFormName() + "|loadAdd|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }//from ww w. jav a 2 s . c om baseDBForm.resetForm(); session.setAttribute(DisplayConstants.CURRENT_ACTION, DisplayConstants.ADD); session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm); session.removeAttribute(DisplayConstants.SEARCH_RESULT); session.setAttribute(DisplayConstants.CREATE_WORKFLOW, DisplayConstants.CREATE_WORKFLOW); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|loadAdd|Success|Loading the Add Page||"); return ForwardConstants.LOAD_ADD_SUCCESS; }
From source file:org.openmrs.web.controller.OptionsFormController.java
/** * Called prior to form display. Allows for data to be put in the request to be used in the view * * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest) */// w ww . j a v a 2 s .com protected Map<String, Object> referenceData(HttpServletRequest request) throws Exception { HttpSession httpSession = request.getSession(); Map<String, Object> map = new HashMap<String, Object>(); if (Context.isAuthenticated()) { LocationService ls = Context.getLocationService(); // set location options map.put("locations", ls.getAllLocations()); AdministrationService as = Context.getAdministrationService(); // set language/locale options map.put("languages", as.getPresentationLocales()); Object resetPasswordAttribute = httpSession.getAttribute("resetPassword"); if (resetPasswordAttribute == null) { resetPasswordAttribute = ""; } else { httpSession.removeAttribute("resetPassword"); } map.put("resetPassword", resetPasswordAttribute); //generate the password hint depending on the security GP settings List<String> hints = new ArrayList<String>(5); int minChar = 1; MessageSourceService mss = Context.getMessageSourceService(); try { String minCharStr = as.getGlobalProperty(OpenmrsConstants.GP_PASSWORD_MINIMUM_LENGTH); if (StringUtils.isNotBlank(minCharStr)) { minChar = Integer.valueOf(minCharStr); } if (minChar < 1) { minChar = 1; } } catch (NumberFormatException e) { //ignore } hints.add(mss.getMessage("options.login.password.minCharacterCount", new Object[] { minChar }, null)); addHint(hints, as.getGlobalProperty(OpenmrsConstants.GP_PASSWORD_CANNOT_MATCH_USERNAME_OR_SYSTEMID), mss.getMessage("options.login.password.cannotMatchUsername")); addHint(hints, as.getGlobalProperty(OpenmrsConstants.GP_PASSWORD_REQUIRES_UPPER_AND_LOWER_CASE), mss.getMessage("options.login.password.containUpperCase")); addHint(hints, as.getGlobalProperty(OpenmrsConstants.GP_PASSWORD_REQUIRES_DIGIT), mss.getMessage("options.login.password.containNumber")); addHint(hints, as.getGlobalProperty(OpenmrsConstants.GP_PASSWORD_REQUIRES_NON_DIGIT), mss.getMessage("options.login.password.containNonNumber")); StringBuilder passwordHint = new StringBuilder(""); for (int i = 0; i < hints.size(); i++) { if (i == 0) { passwordHint.append(hints.get(i)); } else if (i < (hints.size() - 1)) { passwordHint.append(", ").append(hints.get(i)); } else { passwordHint.append(" and ").append(hints.get(i)); } } map.put("passwordHint", passwordHint.toString()); } return map; }
From source file:de.blizzy.documentr.web.page.PageController.java
@RequestMapping(value = "/edit/{projectName:" + DocumentrConstants.PROJECT_NAME_PATTERN + "}/" + "{branchName:" + DocumentrConstants.BRANCH_NAME_PATTERN + "}/" + "{path:" + DocumentrConstants.PAGE_PATH_URL_PATTERN + "}", method = RequestMethod.GET) @PreAuthorize("hasPagePermission(#projectName, #branchName, #path, EDIT_PAGE)") public String editPage(@PathVariable String projectName, @PathVariable String branchName, @PathVariable String path, Model model, HttpSession session) throws IOException { try {/*from w w w . j av a2 s . c o m*/ path = Util.toRealPagePath(path); Page page = pageStore.getPage(projectName, branchName, path, true); String text = ((PageTextData) page.getData()).getText(); String viewRestrictionRole = page.getViewRestrictionRole(); PageMetadata metadata = pageStore.getPageMetadata(projectName, branchName, path); String commit = metadata.getCommit(); MergeConflict conflict = (MergeConflict) session.getAttribute("conflict"); //$NON-NLS-1$ session.removeAttribute("conflict"); //$NON-NLS-1$ if (conflict != null) { projectName = (String) session.getAttribute("conflict.projectName"); //$NON-NLS-1$ session.removeAttribute("conflict.projectName"); //$NON-NLS-1$ branchName = (String) session.getAttribute("conflict.branchName"); //$NON-NLS-1$ session.removeAttribute("conflict.branchName"); //$NON-NLS-1$ path = (String) session.getAttribute("conflict.pagePath"); //$NON-NLS-1$ session.removeAttribute("conflict.pagePath"); //$NON-NLS-1$ text = conflict.getText(); commit = conflict.getNewBaseCommit(); } String[] tags = page.getTags().toArray(ArrayUtils.EMPTY_STRING_ARRAY); Arrays.sort(tags); PageForm form = new PageForm(projectName, branchName, path, page.getParentPagePath(), page.getTitle(), text, (viewRestrictionRole != null) ? viewRestrictionRole : StringUtils.EMPTY, commit, tags); model.addAttribute("pageForm", form); //$NON-NLS-1$ if (conflict != null) { model.addAttribute("mergeConflict", Boolean.TRUE); //$NON-NLS-1$ } return "/project/branch/page/edit"; //$NON-NLS-1$ } catch (PageNotFoundException e) { return ErrorController.notFound("page.notFound"); //$NON-NLS-1$ } }
From source file:com.enonic.vertical.adminweb.AdminLogInServlet.java
private void handlerForgotPasswordForm(HttpServletRequest request, HttpServletResponse response, HttpSession session, HashMap<String, Object> parameters, org.jdom.Document doc) throws VerticalAdminException { final UserStoreXmlCreator xmlCreator = new UserStoreXmlCreator( userStoreService.getUserStoreConnectorConfigs()); List<UserStoreEntity> userStores = securityService.getUserStores(); org.jdom.Document tempDoc = xmlCreator.createPagedDocument(userStores, 0, 100); org.jdom.Element dataElem = doc.getRootElement(); dataElem.addContent(tempDoc.getRootElement().detach()); String errorCode = (String) session.getAttribute("loginerrorcode"); if (errorCode != null) { session.removeAttribute("loginerrorcode"); session.removeAttribute("loginerror"); }/*from ww w.java2 s . co m*/ errorCode = (String) session.getAttribute("passworderrorcode"); if (errorCode != null) { parameters.put("errorcode", errorCode); parameters.put("errormessage", session.getAttribute("passworderror")); } // version and copyright info parameters.put("version", Version.getVersion()); parameters.put("copyright", Version.getCopyright()); String selectedUserStore = (String) session.getAttribute("selectedloginuserstore"); if (StringUtils.isNotEmpty(selectedUserStore)) { parameters.put("selectedloginuserstore", selectedUserStore); } transformXML(request, response, doc, "forgotpwd_form.xsl", parameters); }