Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot get cookie from servlet after RequestDispatcher.forward()

843835Nov 26 2001 — edited Nov 26 2001
Hi gurus, I have a servlet that add a cookie to the response object and call a second servlet by RequestDispatcher.forward(). Why this (second) servlet cannot get the cookie ? If I call /SecondServlet from browser or call it by sendRedirect() I can see the cookie. Thanks

FirstServlet
... response.addCookie(cookie);
... RequestDispatcher disp = httpservletrequest.getRequestDispatcher("/SecondServlet");
disp.forward(request, response);

SecondServlet // no cookie here ! Cookie acookie[] = request.getCookies();
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 24 2001
Added on Nov 26 2001
3 comments
659 views