Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

servlets and cookies

Randy Paries

2003-10-14

Replies:

Hello
i assume this is more of a servlet programming problem that tomcat, but
i hope someone has some insight?


Please tell me i can do this:
1)i go to a jsp page and if it does not find the exist of a cookie it
forwards to a login screen

2) the login screen submits to a servlet, and then set some cookies and
then forwards to the original JSP

3) the orig jsp sees those cookies and life is fine.

well i can not make the servlet set the cookies so that the forwarding
jsp sees those cookies.

====
    Cookie cookie1 = new Cookie("USERID",_User.getUname());
    cookie1.setMaxAge(-1);
    cookie1.setPath("/");
    res.addCookie(cookie1);

    Cookie cookie2 = new Cookie("USERDIR",_User.getDir());
    cookie2.setMaxAge(-1);
    cookie2.setPath("/");
    res.addCookie(cookie2);

    RequestDispatcher disp =
getServletConfig().getServletContext().getRequestDispatcher("/my.jsp");
    disp.include(req,res);


my.jsp does not see the cookies.

if i just refresh the browser the second time in the cookies are there

What the heck am i doing wrong
thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.