I have a requirement when I need to add a cookie in java and then redirect it to another URL. Now this url process should be saved in the cookie that I set, and after processing it, send it to the client. The code is as follows
Cookie cookie = new Cookie("name", "value")
// To make sure cookie is established for all the url paths
cookie.setPath(request.getContextPath());
response.addCookie(cookie);
response.sendRedirect("someNewUrl");
Please help me on how I can save cookies throughout the redirect life cycle and for the client. Thanks in advance.
source
share