struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David G. Friedman" <hum...@ix.netcom.com>
Subject RE: using tiles and setting a cookie
Date Tue, 21 Feb 2006 23:49:56 GMT
Have you tried it without the domain setting to ensure that your chosen domain of ".mysite.com"
isn't interfering with
the cookie handoff?  There is the possibility that the browser is configured to accept anything
other than the exact
hostname, though you have probably looked into that and tried that already.  I made that suggestion
since I've
previously read of problems like that on this list.

Regards,
David

-----Original Message-----
From: brian papa [mailto:brian.papa@gmail.com]
Sent: Tuesday, February 21, 2006 6:42 PM
To: Struts Users Mailing List
Subject: Re: using tiles and setting a cookie


I was unaware of that actually. But, even outside of the debugger the
cookie isn't seen on the client side. And it isn't seen on the next
request. Here's some of the code -

In the controller class (it's an abstract class):

public void execute(ComponentContext componentContext,
HttpServletRequest request,
                        HttpServletResponse response, ServletContext
servletContext) throws Exception {
        Object someObj=
someAbstractMethod(componentContext,request,response,servletContext);
        // set a cookie
        Cookie cookie = new Cookie("cookieName","cookieValue");
        cookie.setDomain(".mysite.com");
        cookie.setMaxAge(-1);
        response.addCookie(cookie);
    }

Later on, in another request, I try to get the cookie using -

Cookie[] cookies = request.getCookies()

But my new cookie is nowhere to be found. As I said in the original
post, in my application it's working fine when I set the cookies in
Actions, but not in Controllers.

On 2/21/06, David G. Friedman <humble@ix.netcom.com> wrote:
> Brian,
>
> When and where are you looking for a value change with your debugger? You do know that
the cookie won't be seen until
> the response ends, right?  The NEW cookie is given to the client's browser and won't
be seen by the server until the
> client's next request.  Can you give the controller method and some relevant code pieces?
>
> Regards,
> David
>
> -----Original Message-----
> From: brian papa [mailto:brian.papa@gmail.com]
> Sent: Tuesday, February 21, 2006 4:47 PM
> To: user@struts.apache.org
> Subject: using tiles and setting a cookie
>
>
> I'm having a problem setting a cookie inside of a Controller class.
>
> My custom controller extends from the base Controller class. Inside of
> my class, I'm simply trying to set a cookie to the
> HttpServletResponse. Inside of a Strut Action class, it's been working
> just fine. But in the controller, the response.addCookie method seems
> to do nothing. Using a debugger I see no value change. No exception is
> thrown and the application seems to progress as if nothing happened.
>
> Any ideas? Did I forget to configure something? Is it a poor practice
> to set a cookie in a Controller in the first place?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


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


Mime
View raw message