You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Cha Cha <Ch...@gmail.com> on 2004/09/20 19:56:44 UTC

Fwd: Setting a Cookie (revised)

Hi all

I need to set a cookie in a method in my action class (my whole app is
HTML so no sessions, just the login screen and a cookie)

three questions
1. How do I set a cookie inside of an Action class that I can check
using javascript? Normally I would do something like

boolean saveUser(String userName, String password, HttpServletResponse
response){
  Cookie c = new Cookie ("validUser", userid);
  c.setMaxAge(3600);
  response.addCookie(c);
  return true;
}

then check it in the jsp or html or whatever. Thoughts? am i on the right track?

2. what's a good site to read about checking for the esistence of
cookies using javascript? I basically need to check if the cookie from
above is there, and if it's not, redirect to the login screen

3. Where is a good example of the <bean:cookie> tag in struts? to
check the above cookie

Thanks!!!

Cha

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org