List of usage examples for javax.servlet.http HttpServletResponse addCookie
public void addCookie(Cookie cookie);
From source file:csns.web.controller.SectionController.java
@RequestMapping("/section/taken") public String taken(@RequestParam(required = false) Quarter quarter, ModelMap models, HttpSession session, HttpServletResponse response) { Cookie cookie = new Cookie("default-home", "/section/taken"); cookie.setPath("/"); cookie.setMaxAge(100000000);// www . ja v a 2s.co m response.addCookie(cookie); return list("taken", quarter, models, session); }
From source file:net.anthonychaves.bookmarks.web.TokenController.java
@RequestMapping(method = RequestMethod.POST) public String rememberMe(HttpSession session, HttpServletResponse response, ModelMap model) { int duration = 168; //hours to remember me for = 1 week User user = (User) session.getAttribute("user"); String tokenId = tokenService.setupNewLoginToken(user); Cookie cookie = new Cookie("loginToken", tokenId); cookie.setMaxAge(duration * 60 * 60); cookie.setPath("/bookmarks"); response.addCookie(cookie); model.addAttribute("status", "success"); return "redirect:/b/user"; }
From source file:csns.web.controller.SectionController.java
@RequestMapping("/section/taught") public String taught(@RequestParam(required = false) Quarter quarter, ModelMap models, HttpSession session, HttpServletResponse response) { Cookie cookie = new Cookie("default-home", "/section/taught"); cookie.setPath("/"); cookie.setMaxAge(100000000);//from w w w.j a v a 2s. co m response.addCookie(cookie); return list("taught", quarter, models, session); }
From source file:org.kievguide.controller.UserController.java
@RequestMapping(value = "/logout", method = RequestMethod.GET) public ModelAndView logOut(HttpServletResponse response) { ModelAndView modelAndView = new ModelAndView(); Cookie logOutCookie = new Cookie("userstatus", "guest"); String userStatus = Util.guestPanel(); modelAndView.addObject("userstatus", userStatus); response.addCookie(logOutCookie); modelAndView.setViewName("redirect:" + "signinredirect"); return modelAndView; }
From source file:csns.web.controller.SectionController.java
@RequestMapping("/section/evaluated") public String evaluated(@RequestParam(required = false) Quarter quarter, ModelMap models, HttpSession session, HttpServletResponse response) { Cookie cookie = new Cookie("default-home", "/section/evaluated"); cookie.setPath("/"); cookie.setMaxAge(100000000);/*www . j ava 2s . c om*/ response.addCookie(cookie); return list("evaluated", quarter, models, session); }
From source file:com.companyname.services.OnLoginSuccessHandler.java
private void setCookies(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { logger.info("setting new security cookies"); PlatAuthentication auth = (PlatAuthentication) authentication; if (auth != null) { response.addCookie( createCookie(request, getAccessTokenCookieName(), (String) auth.getTokens().getAccessToken())); response.addCookie(createCookie(request, getRefreshTokenCookieName(), (String) auth.getTokens().getRefreshToken())); // save the agent host String host = request.getHeader("host"); logger.info("====> agent host = " + host); logger.info("create a new token with name: " + agentHostCookieName); response.addCookie(createCookie(request, getAgentHostCookieName(), host)); }// w ww. jav a 2 s . com }
From source file:org.apache.falcon.resource.admin.AdminResource.java
@GET @Path("clearuser") @Produces(MediaType.TEXT_PLAIN)//from www .ja va 2 s . c o m public String clearUser(@Context HttpServletResponse response) { if (!SecurityUtil.isSecurityEnabled()) { Cookie cookie = new Cookie("hadoop.auth", null); cookie.setPath("/"); cookie.setMaxAge(0); cookie.setSecure(false); response.addCookie(cookie); } // Else, Do not checkin User, security is handled via Kerberos. return "ok"; }
From source file:Controladores.ControladorLogin.java
@RequestMapping("efetua-login") public ModelAndView efetuaLogin(String usuario, String senha, boolean ckSalvaLogin, HttpSession sessao, HttpServletResponse response) { ModelAndView mv;/*from w w w. jav a 2s. c om*/ 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:com.glaf.core.util.RequestUtils.java
public static void setTheme(HttpServletRequest request, HttpServletResponse response) { String theme = request.getParameter("theme"); if (StringUtils.isNotEmpty(theme)) { Cookie cookie = new Cookie(Constants.THEME_COOKIE, theme); cookie.setPath("/"); cookie.setMaxAge(-1);/* w w w. j a va 2 s . com*/ response.addCookie(cookie); Cookie cookie2 = new Cookie("data-theme", "theme-" + theme); cookie2.setPath("/"); cookie2.setMaxAge(-1); response.addCookie(cookie2); } }
From source file:de.berlios.jhelpdesk.web.preferences.LookAndFeelEditController.java
@RequestMapping(value = "/preferences/lookAndFeel.html", method = RequestMethod.POST) public String processForm(@ModelAttribute("preferences") LookAndFeelPreferences lafPreferences, @RequestParam(value = "filterId", required = false) Long filterId, HttpServletRequest request, HttpServletResponse respone, ModelMap map, HttpSession session) { User currentUser = (User) session.getAttribute("user"); if (isPrefsOwnedByUser(lafPreferences, currentUser)) { lafPreferences.setUser(currentUser); currentUser.setLafPreferences(lafPreferences); this.userPreferencesDAO.save(lafPreferences); respone.addCookie(createCookie(request, lafPreferences.getPreferredLocale())); session.setAttribute("user", currentUser); map.addAttribute("preferences", lafPreferences); }/* w w w . j a v a 2 s .com*/ return "preferences/lookAndFeel"; }