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:[EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to