About Question enthuware.jwpv6.2.1248 :
Posted: Sat Mar 07, 2015 10:28 pm
Hello. Why the option 1 is not correct?
as soon as I know there is no need to add cookie to response if value is changed. Never had a problem with code like this
and to test we can forward a request to test without resp.addCookie(c)
The following code will change the value of the cookie as well as resp.addCookie(cookie); will do the same. setMaxAge(aTime) has to work same way as soon as 0 value is set.
Am I missing something?
as soon as I know there is no need to add cookie to response if value is changed. Never had a problem with code like this
Code: Select all
Cookie[] cookies = req.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals("some_name")) {
cookie.setValue("some value");
}
}
}
Code: Select all
RequestDispatcher view = req.getRequestDispatcher("cookieresult.jsp");
view.forward(req, resp);
Am I missing something?