List of usage examples for javax.servlet.http Cookie setPath
public void setPath(String uri)
From source file:es.pode.soporte.seguridad.openId.ui.openid.PreviousProcessingFilter.java
/** * Actualiza el timeout de la cookie de OpenId * @param ServletRequest // w w w . j a v a 2 s .c om * @param ServletResponse * @param nombreCookie * @throws IOException */ private void actualizaCookie(HttpServletRequest request, HttpServletResponse response, String nombreCookie) throws IOException { Cookie cookie = null; if (log.isDebugEnabled()) log.debug("Se coge la cookie " + nombreCookie); cookie = getCookie(nombreCookie, request.getCookies()); int caducidadCookie = (new Integer(this.getAgregaPropertyValue(AgregaProperties.TIMEOUTCOOKIEOPENID))) .intValue(); if (log.isDebugEnabled()) log.debug("caducidadCookie " + caducidadCookie); cookie.setMaxAge(caducidadCookie); cookie.setPath("/"); response.addCookie(cookie); }
From source file:cn.vlabs.umt.ui.servlet.AuthorizationCodeServlet.java
private void doCoremailRequest(HttpServletRequest request, HttpServletResponse response) { String theme = request.getParameter("themeinfo"); if (StringUtils.isNotEmpty(theme) && theme.startsWith("coremail")) { if (StringUtils.isNotEmpty(request.getParameter("rememberUserName"))) { String userName = request.getParameter("userName"); if (StringUtils.isNotEmpty(userName)) { Cookie cookie = new Cookie("passport.remember.user", userName); cookie.setPath("/"); cookie.setMaxAge(14 * 60 * 60 * 24); response.addCookie(cookie); }/*from ww w. j a va 2 s . c o m*/ } else { //cookie Cookie cookie = new Cookie("passport.remember.user", ""); cookie.setPath("/"); cookie.setMaxAge(1); response.addCookie(cookie); } if (StringUtils.isNotEmpty(request.getParameter("secureLogon"))) { request.getSession().setAttribute("coremailSecureLogon", true); } } }
From source file:hudson.security.SecurityRealm.java
/** * Handles the logout processing./*from w w w . jav a2s . c o m*/ * * <p> * The default implementation erases the session and do a few other clean up, then * redirect the user to the URL specified by {@link #getPostLogOutUrl(StaplerRequest, Authentication)}. * * @since 1.314 */ public void doLogout(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { HttpSession session = req.getSession(false); if (session != null) session.invalidate(); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); SecurityContextHolder.clearContext(); // reset remember-me cookie Cookie cookie = new Cookie(ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY, ""); cookie.setMaxAge(0); cookie.setSecure(req.isSecure()); cookie.setHttpOnly(true); cookie.setPath(req.getContextPath().length() > 0 ? req.getContextPath() : "/"); rsp.addCookie(cookie); rsp.sendRedirect2(getPostLogOutUrl(req, auth)); }
From source file:com.spshop.web.ShoppingController.java
@RequestMapping(value = "/createAccount", method = RequestMethod.POST) public String createAccount(Model model, HttpServletRequest request, HttpServletResponse response) { String email = request.getParameter(REG_USER_NAME); String pwd1 = request.getParameter(REG_PWD); String pwd2 = request.getParameter(REG_PWD_RE); if (null != email) { email = email.trim();// w w w. j a v a 2 s .c om } String acceptLicense = request.getParameter(ACCEPT_LICENSE); User user = new User(); user.setName(email); user.setEmail(email); user.setPassword(pwd1); user.setCreateDate(new Date()); user.setUpdateDate(new Date()); if (!TRUE.equals(acceptLicense)) { getUserView().getErr().put(ACCEPT_LICENSE_ERR, "Please accept license"); } String landingpage = null; try { landingpage = URLDecoder.decode(request.getParameter(LOGIN_LANDING_PAGE_PARAM), "utf-8"); } catch (Exception e) { logger.debug(e.getMessage()); } if (null == email || !(email.contains("@"))) { getUserView().getErr().put(REG_USER_NAME_ERR, "Invalid user account"); } else { User u = ServiceFactory.getService(UserService.class).queryUserByEmail(email); if (u != null) { getUserView().getErr().put(REG_USER_NAME_ERR, "account already exist"); } } if (pwd1 == null || pwd1.length() < 5) { getUserView().getErr().put(REG_PWD_ERR, "Invalid password"); } else { if (pwd2 == null || !pwd1.equals(pwd2)) { getUserView().getErr().put(REG_PWD_RE_ERR, "Two passwords are not same"); } } if (getUserView().getErr().isEmpty()) { final User u = ServiceFactory.getService(UserService.class).saveUser(user); if (null != u) { getUserView().getMsg().put(REG_USER_NAME_SUC, "Create Account successfully"); final Map<String, Object> root = new HashMap<String, Object>(); root.put("user", u); u.setPassword(u.getPassword()); model.addAttribute(USER_INFO, u); request.getSession().setAttribute(USER_INFO, u); getUserView().setLoginUser(u); Cookie cookie = new Cookie(COOKIE_ACCOUNT, Utils.OBJ.getEncryString(u.getEmail() + USER_NAME_PWD_SPLIT + u.getPassword())); cookie.setMaxAge(99999999); cookie.setPath("/"); response.addCookie(cookie); new Thread() { public void run() { try { EmailTools.sendMail("register", "Welcome to Honeybuy.com, New Member Registration", root, u.getName()); } catch (Exception e) { } }; }.start(); } } if (StringUtils.isNotBlank(landingpage)) { getUserView().setRequestPage(landingpage); } model.addAttribute(REG_USER, user); return "login"; }
From source file:MyServlet.UserController.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // processRequest(request, response); Object message;/*from w ww . ja v a 2s .co m*/ Object userResetToken; String url = "/main.jsp"; action = request.getParameter("action"); System.out.println("action" + action); PrintWriter writer = response.getWriter(); HttpSession session = request.getSession(); User theUser = (User) session.getAttribute("theUser"); writer.println("Inside get" + action); if (theUser != null) { //writer.println("Inside user"); if (action.equals("about")) { url = "/aboutl.jsp"; } if (action.equals("how")) { url = "/main.jsp"; } if (action.equals("home")) { url = "/main.jsp"; } if (action.equals("main")) { url = "/main.jsp"; } if (action.equals("login")) { url = "/login.jsp"; } if (action.equals("create")) { try { String currentTime = sdf.format(dt); String token = request.getParameter("token"); String expiryTime = UserDB.getTime(token); Date date1 = sdf.parse(expiryTime); Date date2 = sdf.parse(currentTime); long differenceInMillis = date2.getTime() - date1.getTime(); if (differenceInMillis < 3600000) { request.setAttribute("token", token); url = "/signup.jsp"; } } catch (ParseException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } } if (action.equals("activation")) { String currentTime = sdf.format(dt); String value; String userToken; String password; userToken = request.getParameter("activationcode"); System.out.println("userToken if" + userToken); String expiryTime = UserDB.getTime(userToken); try { Date date1 = sdf.parse(expiryTime); Date date2 = sdf.parse(currentTime); long differenceInMillis = date2.getTime() - date1.getTime(); if (differenceInMillis < 3600000) { User user = UserDB.activateUser(userToken); if (user != null) { value = userPassword.get(user.getEmail()); session.setAttribute("theUser", user); try { password = hashAndSalt(value); userDB.addUser(user, password, salt); userDB.addUser(user); userDB.deleteTemp(userToken); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } url = "/login.jsp"; } else { url = "/signup.jsp"; } } } catch (ParseException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } } if (action.equals("resetpassword")) { try { String token; String currentTime = sdf.format(dt); token = request.getParameter("token"); System.out.println("userToken else" + token); String expiryTime = UserDB.getTime(token); Date date1 = sdf.parse(expiryTime); Date date2 = sdf.parse(currentTime); long differenceInMillis = date2.getTime() - date1.getTime(); if (differenceInMillis < 3600000) { User user = UserDB.activateUser(token); if (user != null) { request.setAttribute("user", user); request.setAttribute("userResetToken", token); url = "/resetpassword.jsp"; } else { url = "/signup.jsp"; } } else { message = "Token is expired!!"; request.setAttribute("message", message); url = "/signup.jsp"; } //url="/login.jsp"; } catch (ParseException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } } } else { if (action.equals("about")) { url = "/about.jsp"; } if (action.equals("how")) { url = "/how.jsp"; } if (action.equals("home")) { if (flag == 0) { int i = request.getServerPort(); String port = String.valueOf(i); Cookie myCookie = new Cookie("HostName", request.getServerName()); myCookie.setMaxAge(60 * 60 * 24 * 365); myCookie.setPath("/"); response.addCookie(myCookie); Cookie cookiePort = new Cookie("Port", port); myCookie.setMaxAge(60 * 60 * 24 * 365); myCookie.setPath("/"); response.addCookie(cookiePort); } url = "/home.jsp"; flag++; } if (action.equals("main")) { url = "/login.jsp"; } if (action.equals("login")) { url = "/login.jsp"; } if (action.equals("activation")) { String currentTime = sdf.format(dt); String value; String userToken; String password; userToken = request.getParameter("activationcode"); System.out.println("userToken else" + userToken); String expiryTime = UserDB.getTime(userToken); try { Date date1 = sdf.parse(expiryTime); Date date2 = sdf.parse(currentTime); long differenceInMillis = date2.getTime() - date1.getTime(); if (differenceInMillis < 3600000) { User user = UserDB.activateUser(userToken); if (user != null) { value = userPassword.get(user.getEmail()); session.setAttribute("theUser", user); try { password = hashAndSalt(value); userDB.addUser(user, password, salt); userDB.addUser(user); userDB.deleteTemp(userToken); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } url = "/login.jsp"; } else { url = "/signup.jsp"; } } } catch (ParseException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } } if (action.equals("resetpassword")) { try { String token; String currentTime = sdf.format(dt); token = request.getParameter("token"); System.out.println("userToken else" + token); String expiryTime = UserDB.getTime(token); Date date1 = sdf.parse(expiryTime); Date date2 = sdf.parse(currentTime); long differenceInMillis = date2.getTime() - date1.getTime(); if (differenceInMillis < 3600000) { User user = UserDB.activateUser(token); if (user != null) { request.setAttribute("user", user); request.setAttribute("userResetToken", token); url = "/resetpassword.jsp"; } else { url = "/signup.jsp"; } } else { message = "Token is expired!!"; request.setAttribute("message", message); url = "/signup.jsp"; } //url="/login.jsp"; } catch (ParseException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } } } getServletContext().getRequestDispatcher(url).forward(request, response); }
From source file:cn.tiup.httpproxy.ProxyServlet.java
/** Copy cookie from the proxy to the servlet client. * Replaces cookie path to local path and renames cookie to avoid collisions. *///from w w w . j a va2 s . com protected void copyProxyCookie(HttpServletRequest servletRequest, HttpServletResponse servletResponse, String headerValue) { List<HttpCookie> cookies = HttpCookie.parse(headerValue); for (HttpCookie cookie : cookies) { //set cookie name prefixed w/ a proxy value so it won't collide w/ other cookies String proxyCookieName = getCookieNamePrefix(cookie.getName()) + cookie.getName(); Cookie servletCookie = new Cookie(proxyCookieName, cookie.getValue()); servletCookie.setComment(cookie.getComment()); servletCookie.setMaxAge((int) cookie.getMaxAge()); servletCookie.setPath(cookie.getPath()); //set to the path of the proxy servlet // don't set cookie domain servletCookie.setSecure(cookie.getSecure()); servletCookie.setVersion(cookie.getVersion()); servletResponse.addCookie(servletCookie); } }
From source file:net.geant.edugain.filter.EduGAINFilter.java
private void attachCookies(String name, HashMap<String, String> attrs, HttpServletResponse response, boolean outdated) throws ServletException { String maxAge = "0"; Cookie lcook = null; if (!outdated) { lcook = new Cookie(name, cipher.encode(name, generateCookie(attrs, outdated))); } else {/*from w ww . j a v a 2s .c o m*/ lcook = new Cookie(name, ""); lcook.setMaxAge(Integer.parseInt(maxAge)); } lcook.setPath(this.location); response.addCookie(lcook); }
From source file:com.sourcesense.confluence.servlets.CMISProxyServlet.java
/** * Executes the {@link HttpMethod} passed in and sends the proxy response * back to the client via the given {@link HttpServletResponse} * * @param httpMethodProxyRequest An object representing the proxy request to be made * @param httpServletResponse An object by which we can send the proxied * response back to the client * @param httpServletRequest Request object pertaining to the proxied HTTP request * @throws IOException Can be thrown by the {@link HttpClient}.executeMethod * @throws ServletException Can be thrown to indicate that another error has occurred */// w ww .j a va2 s . c o m private void executeProxyRequest(HttpMethod httpMethodProxyRequest, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException { // Create a default HttpClient HttpClient httpClient = new HttpClient(); getCredential(httpServletRequest.getParameter("servername")); if (credentials != null) { httpClient.getParams().setAuthenticationPreemptive(true); httpClient.getState().setCredentials(AuthScope.ANY, credentials); } httpMethodProxyRequest.setFollowRedirects(true); // Execute the request int intProxyResponseCode = httpClient.executeMethod(httpMethodProxyRequest); String response = httpMethodProxyRequest.getResponseBodyAsString(); // Check if the proxy response is a redirect // The following code is adapted from org.tigris.noodle.filters.CheckForRedirect // Hooray for open source software if (intProxyResponseCode >= HttpServletResponse.SC_MULTIPLE_CHOICES /* 300 */ && intProxyResponseCode < HttpServletResponse.SC_NOT_MODIFIED /* 304 */) { String stringStatusCode = Integer.toString(intProxyResponseCode); String stringLocation = httpMethodProxyRequest.getResponseHeader(STRING_LOCATION_HEADER).getValue(); if (stringLocation == null) { throw new ServletException("Received status code: " + stringStatusCode + " but no " + STRING_LOCATION_HEADER + " header was found in the response"); } // Modify the redirect to go to this proxy servlet rather that the proxied host String stringMyHostName = httpServletRequest.getServerName(); if (httpServletRequest.getServerPort() != 80) { stringMyHostName += ":" + httpServletRequest.getServerPort(); } stringMyHostName += httpServletRequest.getContextPath(); if (followRedirects) { if (stringLocation.contains("jsessionid")) { Cookie cookie = new Cookie("JSESSIONID", stringLocation.substring(stringLocation.indexOf("jsessionid=") + 11)); cookie.setPath("/"); httpServletResponse.addCookie(cookie); //debug("redirecting: set jessionid (" + cookie.getValue() + ") cookie from URL"); } else if (httpMethodProxyRequest.getResponseHeader("Set-Cookie") != null) { Header header = httpMethodProxyRequest.getResponseHeader("Set-Cookie"); String[] cookieDetails = header.getValue().split(";"); String[] nameValue = cookieDetails[0].split("="); Cookie cookie = new Cookie(nameValue[0], nameValue[1]); cookie.setPath("/"); //debug("redirecting: setting cookie: " + cookie.getName() + ":" + cookie.getValue() + " on " + cookie.getPath()); httpServletResponse.addCookie(cookie); } httpServletResponse.sendRedirect(stringLocation .replace(getProxyHostAndPort(httpServletRequest) + this.getProxyPath(), stringMyHostName)); return; } } else if (intProxyResponseCode == HttpServletResponse.SC_NOT_MODIFIED) { // 304 needs special handling. See: // http://www.ics.uci.edu/pub/ietf/http/rfc1945.html#Code304 // We get a 304 whenever passed an 'If-Modified-Since' // header and the data on disk has not changed; server // responds w/ a 304 saying I'm not going to send the // body because the file has not changed. httpServletResponse.setIntHeader(STRING_CONTENT_LENGTH_HEADER_NAME, 0); httpServletResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return; } // Pass the response code back to the client httpServletResponse.setStatus(intProxyResponseCode); // Pass response headers back to the client Header[] headerArrayResponse = httpMethodProxyRequest.getResponseHeaders(); for (Header header : headerArrayResponse) { if (header.getName().equals("Transfer-Encoding") && header.getValue().equals("chunked") || header.getName().equals("Content-Encoding") && header.getValue().equals("gzip") || // don't copy gzip header header.getName().equals("WWW-Authenticate")) { // don't copy WWW-Authenticate header so browser doesn't prompt on failed basic auth // proxy servlet does not support chunked encoding } else { httpServletResponse.setHeader(header.getName(), header.getValue()); } } List<Header> responseHeaders = Arrays.asList(headerArrayResponse); if (isBodyParameterGzipped(responseHeaders)) { debug("GZipped: true"); if (!followRedirects && intProxyResponseCode == HttpServletResponse.SC_MOVED_TEMPORARILY) { response = httpMethodProxyRequest.getResponseHeader(STRING_LOCATION_HEADER).getValue(); httpServletResponse.setStatus(HttpServletResponse.SC_OK); intProxyResponseCode = HttpServletResponse.SC_OK; httpServletResponse.setHeader(STRING_LOCATION_HEADER, response); } else { response = new String(ungzip(httpMethodProxyRequest.getResponseBody())); } httpServletResponse.setContentLength(response.length()); } // Send the content to the client if (intProxyResponseCode == 200) httpServletResponse.getWriter().write(response); else httpServletResponse.getWriter().write(intProxyResponseCode); }
From source file:com.liferay.portal.servlet.MainServlet.java
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { if (!PortalInstances.matches()) { String html = ContentUtil.get("messages/en_US/init.html"); res.getOutputStream().print(html); return;//from ww w . jav a 2 s . c o m } if (ShutdownUtil.isShutdown()) { String html = ContentUtil.get("messages/en_US/shutdown.html"); res.getOutputStream().print(html); return; } req.setAttribute("dotcache", "no"); // Shared session HttpSession ses = req.getSession(); if (!GetterUtil.getBoolean(PropsUtil.get(PropsUtil.TCK_URL))) { String sharedSessionId = CookieUtil.get(req.getCookies(), CookieKeys.SHARED_SESSION_ID); _log.debug("Shared session id is " + sharedSessionId); if (sharedSessionId == null) { sharedSessionId = PwdGenerator.getPassword(PwdGenerator.KEY1 + PwdGenerator.KEY2, 12); Cookie sharedSessionIdCookie = new Cookie(CookieKeys.SHARED_SESSION_ID, sharedSessionId); sharedSessionIdCookie.setPath("/"); sharedSessionIdCookie.setMaxAge(86400); res.addCookie(sharedSessionIdCookie); _log.debug("Shared session id is " + sharedSessionId); } // if (ses.getAttribute(WebKeys.SHARED_SESSION_ID) == null) { ses.setAttribute(WebKeys.SHARED_SESSION_ID, sharedSessionId); // } HttpSession portalSes = (HttpSession) SharedSessionPool.get(sharedSessionId); if ((portalSes == null) || (ses != portalSes)) { if (portalSes == null) { _log.debug("No session exists in pool"); } else { _log.debug("Session " + portalSes.getId() + " in pool is old"); } _log.debug("Inserting current session " + ses.getId() + " in pool"); SharedSessionPool.put(sharedSessionId, ses); } } // Test CAS auto login /* * ses.setAttribute( * com.liferay.portal.auth.CASAutoLogin.CAS_FILTER_USER, * "liferay.com.1"); */ // CTX ServletContext ctx = getServletContext(); ServletContext portalCtx = ctx.getContext(PropsUtil.get(PropsUtil.PORTAL_CTX)); if (portalCtx == null) { portalCtx = ctx; } req.setAttribute(WebKeys.CTX, portalCtx); // CTX_PATH variable String ctxPath = (String) ctx.getAttribute(WebKeys.CTX_PATH); if (portalCtx.getAttribute(WebKeys.CTX_PATH) == null) { portalCtx.setAttribute(WebKeys.CTX_PATH, ctxPath); } if (ses.getAttribute(WebKeys.CTX_PATH) == null) { ses.setAttribute(WebKeys.CTX_PATH, ctxPath); } req.setAttribute(WebKeys.CTX_PATH, ctxPath); // CAPTCHA_PATH variable String captchaPath = (String) ctx.getAttribute(WebKeys.CAPTCHA_PATH); if (portalCtx.getAttribute(WebKeys.CAPTCHA_PATH) == null) { portalCtx.setAttribute(WebKeys.CAPTCHA_PATH, captchaPath); } if (ses.getAttribute(WebKeys.CAPTCHA_PATH) == null) { ses.setAttribute(WebKeys.CAPTCHA_PATH, captchaPath); } req.setAttribute(WebKeys.CAPTCHA_PATH, captchaPath); // IMAGE_PATH variable String imagePath = (String) ctx.getAttribute(WebKeys.IMAGE_PATH); if (portalCtx.getAttribute(WebKeys.IMAGE_PATH) == null) { portalCtx.setAttribute(WebKeys.IMAGE_PATH, imagePath); } if (ses.getAttribute(WebKeys.IMAGE_PATH) == null) { ses.setAttribute(WebKeys.IMAGE_PATH, imagePath); } req.setAttribute(WebKeys.IMAGE_PATH, imagePath); // WebKeys.COMPANY_ID variable String companyId = (String) ctx.getAttribute(WebKeys.COMPANY_ID); if (portalCtx.getAttribute(WebKeys.COMPANY_ID) == null) { portalCtx.setAttribute(WebKeys.COMPANY_ID, companyId); } if (ses.getAttribute(WebKeys.COMPANY_ID) == null) { ses.setAttribute(WebKeys.COMPANY_ID, companyId); } req.setAttribute(WebKeys.COMPANY_ID, companyId); // Portlet Request Processor PortletRequestProcessor portletReqProcessor = (PortletRequestProcessor) portalCtx .getAttribute(WebKeys.PORTLET_STRUTS_PROCESSOR); if (portletReqProcessor == null) { portletReqProcessor = new PortletRequestProcessor(this, getModuleConfig(req)); portalCtx.setAttribute(WebKeys.PORTLET_STRUTS_PROCESSOR, portletReqProcessor); } // Tiles definitions factory if (portalCtx.getAttribute(TilesUtilImpl.DEFINITIONS_FACTORY) == null) { portalCtx.setAttribute(TilesUtilImpl.DEFINITIONS_FACTORY, ctx.getAttribute(TilesUtilImpl.DEFINITIONS_FACTORY)); } // Set character encoding String strutsCharEncoding = PropsUtil.get(PropsUtil.STRUTS_CHAR_ENCODING); req.setCharacterEncoding(strutsCharEncoding); /* * if (!BrowserSniffer.is_wml(req)) { res.setContentType( * Constants.TEXT_HTML + "; charset=" + strutsCharEncoding); } */ // Determine content type String contentType = req.getHeader("Content-Type"); if ((contentType != null) && (contentType.startsWith("multipart/form-data"))) { req = new UploadServletRequest(req); } else if (ParamUtil.get(req, WebKeys.ENCRYPT, false)) { try { Company company = CompanyLocalManagerUtil.getCompany(companyId); req = new EncryptedServletRequest(req, company.getKeyObj()); } catch (Exception e) { } } // Current URL String completeURL = Http.getCompleteURL(req); if (completeURL.indexOf("j_security_check") != -1) { completeURL = ctxPath; } else { completeURL = completeURL.substring(completeURL.indexOf("://") + 3, completeURL.length()); completeURL = completeURL.substring(completeURL.indexOf("/"), completeURL.length()); } req.setAttribute(WebKeys.CURRENT_URL, completeURL); // Chat server // Login String userId = PortalUtil.getUserId(req); if ((userId != null)) { PrincipalThreadLocal.setName(userId); } if (userId == null) { try { User user = UserManagerUtil.getDefaultUser(companyId); if (ses.getAttribute(Globals.LOCALE_KEY) == null) ses.setAttribute(Globals.LOCALE_KEY, user.getLocale()); } catch (Exception e) { Logger.error(this, e.getMessage(), e); } } // Process pre service events try { EventsProcessor.process(PropsUtil.getArray(PropsUtil.SERVLET_SERVICE_EVENTS_PRE), req, res); } catch (Exception e) { Logger.error(this, e.getMessage(), e); req.setAttribute(PageContext.EXCEPTION, e); StrutsUtil.forward(PropsUtil.get(PropsUtil.SERVLET_SERVICE_EVENTS_PRE_ERROR_PAGE), portalCtx, req, res); } // Struts service callParentService(req, res); // Process post service events try { EventsProcessor.process(PropsUtil.getArray(PropsUtil.SERVLET_SERVICE_EVENTS_POST), req, res); } catch (Exception e) { Logger.error(this, e.getMessage(), e); } // Clear the principal associated with this thread PrincipalThreadLocal.setName(null); }