List of usage examples for javax.servlet.http HttpServletResponse addCookie
public void addCookie(Cookie cookie);
From source file:architecture.ee.web.util.CookieUtils.java
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, int maxAge) { if (value == null) value = ""; String path = request.getContextPath() != null ? request.getContextPath() : "/"; if ("".equals(path)) path = "/"; Cookie cookie = new Cookie(name, value); cookie.setMaxAge(maxAge);//from w ww. j a v a2s . c o m cookie.setPath(path); response.addCookie(cookie); }
From source file:modelo.AutenticacionManager.Autenticacion.java
private static void variablesSession(HttpSession sesion, HttpServletResponse response, String login, String rol, String ip) {/* www. j a v a2 s.c o m*/ //public static void variablesSession(HttpSession sesion, String login, String ip, String rol, String persona, String codigoPersona) { sesion.setAttribute("login", login); sesion.setAttribute("ip", ip); Cookie ssocookie = new Cookie("login", encode(login)); ssocookie.setPath("/"); response.addCookie(ssocookie); ssocookie = new Cookie("ip", encode(ip)); ssocookie.setPath("/"); response.addCookie(ssocookie); /*ssocookie = new Cookie("rol", encode(rol)); ssocookie.setPath("/"); response.addCookie(ssocookie);*/ }
From source file:com.leixl.easyframework.web.CookieUtils.java
/** * ?cookie/*from w w w . j av a 2 s . co m*/ * * @param request * @param response * @param name * @param domain */ public static void cancleCookie(HttpServletRequest request, HttpServletResponse response, String name, String domain) { Cookie cookie = new Cookie(name, ""); cookie.setMaxAge(0); String ctx = request.getContextPath(); cookie.setPath(StringUtils.isBlank(ctx) ? "/" : ctx); if (StringUtils.isNotBlank(domain)) { cookie.setDomain(domain); } response.addCookie(cookie); }
From source file:net.bluehornreader.web.WebUtils.java
private static void saveCookie(HttpServletResponse httpServletResponse, boolean secured, String name, String value, int expires) { Cookie cookie = new Cookie(name, value); cookie.setHttpOnly(true);//from w ww .ja v a 2s . c om cookie.setMaxAge(expires); cookie.setPath("/"); if (secured) { cookie.setSecure(true); } LOG.info(cookieAsString(cookie)); httpServletResponse.addCookie(cookie); }
From source file:ai.susi.server.AbstractAPIHandler.java
/** * Delete the login cookie if present/*from ww w. j ava2s.c o m*/ * @param response */ protected static void deleteLoginCookie(HttpServletResponse response) { Cookie deleteCookie = new Cookie("login", null); deleteCookie.setPath("/"); deleteCookie.setMaxAge(0); response.addCookie(deleteCookie); }
From source file:io.lavagna.web.helper.UserSession.java
public static void invalidate(HttpServletRequest req, HttpServletResponse resp, UserRepository userRepository) { req.getSession().invalidate();// w w w. j ava 2 s. c o m Cookie c = getCookie(req, "LAVAGNA_REMEMBER_ME"); if (c != null) { deleteTokenIfExist(c.getValue(), userRepository); c.setMaxAge(0); c.setValue(null); resp.addCookie(c); } }
From source file:com.rantop.web.util.web.ServletUtils.java
/** * Convenience method for deleting a cookie by name * * @param response the current web response * @param cookie the cookie to delete//from ww w . java 2 s .co m * @param path the path on which the cookie was set (i.e. /appfuse) */ public static void deleteCookie(HttpServletResponse response, Cookie cookie, String path) { if (cookie != null) { // Delete the cookie by setting its maximum age to zero cookie.setMaxAge(0); cookie.setPath(path); response.addCookie(cookie); } }
From source file:fr.paris.lutece.portal.service.portal.ThemesService.java
/** * Sets the users theme using a cookie/*ww w. j a v a 2 s. co m*/ * @param request The HTTP request * @param response The HTTP response * @param strTheme The Theme code */ public static void setUserTheme(HttpServletRequest request, HttpServletResponse response, String strTheme) { Cookie cookie = new Cookie(COOKIE_NAME, strTheme); response.addCookie(cookie); }
From source file:com.bacic5i5j.framework.toolbox.web.WebUtils.java
/** * cookie?// w w w.ja va 2s . c o m * * @param response * @param name * @param value * @param domain * @param expiry */ public static void setCookie(HttpServletResponse response, String name, String value, String domain, int expiry) { Cookie cookie = new Cookie(name, value); cookie.setDomain(domain); cookie.setPath("/"); cookie.setMaxAge(expiry); response.addCookie(cookie); }
From source file:com.ax.utils.CookieUtils.java
/** * Deletes the specified cookie./*from www .j av a 2 s.c o m*/ * * @param request * the servlet request. * @param response * the servlet response. * @param cookie * the cookie object to be deleted. * @param path * the path. */ public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, Cookie cookie, String path) { if (cookie != null) { // Invalidate the cookie if (StringUtils.isEmpty(path)) { path = "/"; } cookie.setPath(path); cookie.setValue(""); cookie.setMaxAge(0); response.addCookie(cookie); } }