No, I'm not seeing an exception for that.

I'm starting to think now that perhaps I'm doing this in the wrong
place. After all the purpose of a controller should simply be to
prepare data for rendering in a JSP tile. I'm wondering though if this
is the case what the purpose is of having the HttpServletRequest as a
parameter to a Controller?

I'm now considering moving my database code into an action, and then
setting the cookie in there before handing off to a slimmed-down
controller.

On 2/21/06, David G. Friedman <[EMAIL PROTECTED]> wrote:
> Brian,
>
> Are your logs showing any errors about the reponse already being committed?  
> If the headers have already been sent then
> adding cookies after that would be a useless task.  But I think you would 
> probably have seen Java Exceptions at that
> point.
>
> -David
>
> -----Original Message-----
> From: brian papa [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 21, 2006 6:59 PM
> To: Struts Users Mailing List
> Subject: Re: using tiles and setting a cookie
>
>
> Yeah that doesn't seem to be the problem, and the ".mysite.com" is
> working with an Action anyway... setting the cookie the same exact
> way.
>
> I'm wondering if this is some trouble with tiles. I see using my
> debugger that the internals of the Response object in a Controller
> seem different then it does in an Action.
>
> On 2/21/06, David G. Friedman <[EMAIL PROTECTED]> wrote:
> > 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]
> >
> >
>
> ---------------------------------------------------------------------
> 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