You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by john lee <sh...@yahoo.com> on 2007/06/12 17:03:05 UTC

response.addCookie not working inside Struts action class


    inside Struts(1.x) Action class, within method
   
  public ActionForward(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
   
  i did the following:
   
  ...
  Cookie me;
  me=new Cookie("LoginID","xxx");
  me.setMaxAge(30*24*60*60);
  response.addCookie(me);
  ...
  return mapping.findFroward("success");
   
  but no cookie(LoginID) is generated at local harddisk, what could be happen? inside Struts action class, can not call Cookie function?
   
  any clue? tks in advance
   
  john
   
    
---------------------------------
  Need a vacation? Get great deals to amazing places on Yahoo! Travel. 

       
---------------------------------
Shape Yahoo! in your own image.  Join our Network Research Panel today!

Re: response.addCookie not working inside Struts action class

Posted by Dave Newton <ne...@yahoo.com>.
Huh?!

--- Chris Pratt <th...@gmail.com> wrote:
> Where'd you get the response?  Does your action
> implement ServletResponseAware?
> 
> On 6/12/07, john lee wrote:
> >     inside Struts(1.x) Action class, within method
> >
> >   public ActionForward(ActionMapping mapping,
> ActionForm form,
> > HttpServletRequest request, HttpServletResponse
> response) throws Exception

d.



       
____________________________________________________________________________________
Choose the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/

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


Re: response.addCookie not working inside Struts action class

Posted by john lee <sh...@yahoo.com>.
i have an login.jsp first, then call action class, if success, then action class forward to different jsp page.
   
  my struts-configure.xml will be as the following:
   
  <action path="/login"
    type="mypackage.LoginAction"
    scope="session"
    <forward name="success" path="/display.jsp" redirect="yes" />
  </action>
   
  I even tried both redirect="yes" option and "without" option as well, but still not see the cooke generate.
   
  tks in advance
   
  john 
   
   

Chris Pratt <th...@gmail.com> wrote:
  Where'd you get the response? Does your action implement
ServletResponseAware?
(*Chris*)

On 6/12/07, john lee wrote:
>
>
>
> inside Struts(1.x) Action class, within method
>
> public ActionForward(ActionMapping mapping, ActionForm form,
> HttpServletRequest request, HttpServletResponse response) throws Exception
>
> i did the following:
>
> ...
> Cookie me;
> me=new Cookie("LoginID","xxx");
> me.setMaxAge(30*24*60*60);
> response.addCookie(me);
> ...
> return mapping.findFroward("success");
>
> but no cookie(LoginID) is generated at local harddisk, what could be
> happen? inside Struts action class, can not call Cookie function?
>
> any clue? tks in advance
>
> john
>
>
> ---------------------------------
> Need a vacation? Get great deals to amazing places on Yahoo! Travel.
>
>
> ---------------------------------
> Shape Yahoo! in your own image. Join our Network Research Panel today!


       
---------------------------------
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out. 

Re: response.addCookie not working inside Struts action class

Posted by Chris Pratt <th...@gmail.com>.
Where'd you get the response?  Does your action implement
ServletResponseAware?
  (*Chris*)

On 6/12/07, john lee <sh...@yahoo.com> wrote:
>
>
>
>     inside Struts(1.x) Action class, within method
>
>   public ActionForward(ActionMapping mapping, ActionForm form,
> HttpServletRequest request, HttpServletResponse response) throws Exception
>
>   i did the following:
>
>   ...
>   Cookie me;
>   me=new Cookie("LoginID","xxx");
>   me.setMaxAge(30*24*60*60);
>   response.addCookie(me);
>   ...
>   return mapping.findFroward("success");
>
>   but no cookie(LoginID) is generated at local harddisk, what could be
> happen? inside Struts action class, can not call Cookie function?
>
>   any clue? tks in advance
>
>   john
>
>
> ---------------------------------
>   Need a vacation? Get great deals to amazing places on Yahoo! Travel.
>
>
> ---------------------------------
> Shape Yahoo! in your own image.  Join our Network Research Panel today!

Re: response.addCookie not working inside Struts action class

Posted by nuwan chandrasoma <my...@gmail.com>.
I also agree with you Dave, +1

Does any one need a guy for a Struts2 project?, i am ready to quit my
current job :))


On 6/12/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- Chris Pratt <th...@gmail.com> wrote:
> > Sorry, for some reason I was stuck on Struts 2.
>
> It's 'cuz it's so much better :D
>
> > I suspect it may have to do with setting the path or
> > domain, but that's just a guess.
>
> +1
>
> d.
>
>
>
>
>
> ____________________________________________________________________________________
> Get your own web address.
> Have a HUGE year through Yahoo! Small Business.
> http://smallbusiness.yahoo.com/domains/?p=BESTDEAL
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: response.addCookie not working inside Struts action class

Posted by Dave Newton <ne...@yahoo.com>.
--- Chris Pratt <th...@gmail.com> wrote:
> Sorry, for some reason I was stuck on Struts 2.

It's 'cuz it's so much better :D

> I suspect it may have to do with setting the path or
> domain, but that's just a guess.

+1

d.



 
____________________________________________________________________________________
Get your own web address.  
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL

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


Re: response.addCookie not working inside Struts action class

Posted by Nuwan Chandrasoma <my...@gmail.com>.
Hi,

Why dont you load a jsp page after this action and have the below tag in the 
page and do a bean write and see

<bean:cookie id="myCookie" name="LoginID" value="0"/>
<bean:write name="myCookie"/>

Thanks,

Nuwan



----- Original Message ----- 
From: "Chris Pratt" <th...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, June 12, 2007 4:42 PM
Subject: Re: response.addCookie not working inside Struts action class


> Sorry, for some reason I was stuck on Struts 2.  In IE's Internet Options,
> on the Privacy tab, click the Advanced... button and check the "Override
> automatic cookie handling" checkbox, then set both cookie types to Prompt.
> After that, try again and you'll be able to see all the cookies that are
> passed to the browser.  I suspect it may have to do with setting the path 
> or
> domain, but that's just a guess.
>  (*Chris*)
>
> On 6/12/07, john lee <sh...@yahoo.com> wrote:
>>
>> the action is executing, checked.
>>
>>   also check the cookie under c:\document and setting\username\cookie, 
>> but
>> not there,
>>
>>   john
>>
>> Dave Newton <ne...@yahoo.com> wrote:
>>   I'd check two things first:
>>
>> 1) Make sure the action is actually executing (via
>> breakpoint or logging)
>>
>> 2) where specifically are you checking to see if the
>> cookie (physically) exists?
>>
>> d.
>>
>> --- john lee wrote:
>>
>> >
>> >
>> > inside Struts(1.x) Action class, within method
>> >
>> > public ActionForward(ActionMapping mapping,
>> > ActionForm form, HttpServletRequest request,
>> > HttpServletResponse response) throws Exception
>> >
>> > i did the following:
>> >
>> > ...
>> > Cookie me;
>> > me=new Cookie("LoginID","xxx");
>> > me.setMaxAge(30*24*60*60);
>> > response.addCookie(me);
>> > ...
>> > return mapping.findFroward("success");
>> >
>> > but no cookie(LoginID) is generated at local
>> > harddisk, what could be happen? inside Struts action
>> > class, can not call Cookie function?
>> >
>> > any clue? tks in advance
>> >
>> > john
>> >
>> >
>> > ---------------------------------
>> > Need a vacation? Get great deals to amazing places
>> > on Yahoo! Travel.
>> >
>> >
>> > ---------------------------------
>> > Shape Yahoo! in your own image. Join our Network
>> > Research Panel today!
>>
>>
>>
>>
>>
>> ____________________________________________________________________________________
>> Get the free Yahoo! toolbar and rest assured with the added security of
>> spyware protection.
>> http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
>> ---------------------------------
>> Yahoo! oneSearch: Finally,  mobile search that gives answers, not web
>> links.
> 


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


Re: response.addCookie not working inside Struts action class

Posted by Chris Pratt <th...@gmail.com>.
Sorry, for some reason I was stuck on Struts 2.  In IE's Internet Options,
on the Privacy tab, click the Advanced... button and check the "Override
automatic cookie handling" checkbox, then set both cookie types to Prompt.
After that, try again and you'll be able to see all the cookies that are
passed to the browser.  I suspect it may have to do with setting the path or
domain, but that's just a guess.
  (*Chris*)

On 6/12/07, john lee <sh...@yahoo.com> wrote:
>
> the action is executing, checked.
>
>   also check the cookie under c:\document and setting\username\cookie, but
> not there,
>
>   john
>
> Dave Newton <ne...@yahoo.com> wrote:
>   I'd check two things first:
>
> 1) Make sure the action is actually executing (via
> breakpoint or logging)
>
> 2) where specifically are you checking to see if the
> cookie (physically) exists?
>
> d.
>
> --- john lee wrote:
>
> >
> >
> > inside Struts(1.x) Action class, within method
> >
> > public ActionForward(ActionMapping mapping,
> > ActionForm form, HttpServletRequest request,
> > HttpServletResponse response) throws Exception
> >
> > i did the following:
> >
> > ...
> > Cookie me;
> > me=new Cookie("LoginID","xxx");
> > me.setMaxAge(30*24*60*60);
> > response.addCookie(me);
> > ...
> > return mapping.findFroward("success");
> >
> > but no cookie(LoginID) is generated at local
> > harddisk, what could be happen? inside Struts action
> > class, can not call Cookie function?
> >
> > any clue? tks in advance
> >
> > john
> >
> >
> > ---------------------------------
> > Need a vacation? Get great deals to amazing places
> > on Yahoo! Travel.
> >
> >
> > ---------------------------------
> > Shape Yahoo! in your own image. Join our Network
> > Research Panel today!
>
>
>
>
>
> ____________________________________________________________________________________
> Get the free Yahoo! toolbar and rest assured with the added security of
> spyware protection.
> http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
> ---------------------------------
> Yahoo! oneSearch: Finally,  mobile search that gives answers, not web
> links.

Re: response.addCookie not working inside Struts action class

Posted by Dave Newton <ne...@yahoo.com>.
--- john lee <sh...@yahoo.com> wrote:
>   also check the cookie under c:\document and
> setting\username\cookie, but not there, 

Where? My cookies, at least, are stored per-browser,
in various places. Check via the browser. Also check
browser settings to make sure cookies are allowed for
the URL you're browsing to.

I'd just be really surprised if the cookie-creation
process itself was hosed up since most of us use it
w/o any issues.

d.



       
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/

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


Re: response.addCookie not working inside Struts action class

Posted by john lee <sh...@yahoo.com>.
the action is executing, checked.
   
  also check the cookie under c:\document and setting\username\cookie, but not there, 
   
  john

Dave Newton <ne...@yahoo.com> wrote:
  I'd check two things first:

1) Make sure the action is actually executing (via
breakpoint or logging)

2) where specifically are you checking to see if the
cookie (physically) exists?

d.

--- john lee wrote:

> 
> 
> inside Struts(1.x) Action class, within method
> 
> public ActionForward(ActionMapping mapping,
> ActionForm form, HttpServletRequest request,
> HttpServletResponse response) throws Exception
> 
> i did the following:
> 
> ...
> Cookie me;
> me=new Cookie("LoginID","xxx");
> me.setMaxAge(30*24*60*60);
> response.addCookie(me);
> ...
> return mapping.findFroward("success");
> 
> but no cookie(LoginID) is generated at local
> harddisk, what could be happen? inside Struts action
> class, can not call Cookie function?
> 
> any clue? tks in advance
> 
> john
> 
> 
> ---------------------------------
> Need a vacation? Get great deals to amazing places
> on Yahoo! Travel. 
> 
> 
> ---------------------------------
> Shape Yahoo! in your own image. Join our Network
> Research Panel today!




____________________________________________________________________________________
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php

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



       
---------------------------------
Yahoo! oneSearch: Finally,  mobile search that gives answers, not web links. 

Re: response.addCookie not working inside Struts action class

Posted by Dave Newton <ne...@yahoo.com>.
I'd check two things first:

1) Make sure the action is actually executing (via
breakpoint or logging)

2) where specifically are you checking to see if the
cookie (physically) exists?

d.

--- john lee <sh...@yahoo.com> wrote:

> 
> 
>     inside Struts(1.x) Action class, within method
>    
>   public ActionForward(ActionMapping mapping,
> ActionForm form, HttpServletRequest request,
> HttpServletResponse response) throws Exception
>    
>   i did the following:
>    
>   ...
>   Cookie me;
>   me=new Cookie("LoginID","xxx");
>   me.setMaxAge(30*24*60*60);
>   response.addCookie(me);
>   ...
>   return mapping.findFroward("success");
>    
>   but no cookie(LoginID) is generated at local
> harddisk, what could be happen? inside Struts action
> class, can not call Cookie function?
>    
>   any clue? tks in advance
>    
>   john
>    
>     
> ---------------------------------
>   Need a vacation? Get great deals to amazing places
> on Yahoo! Travel. 
> 
>        
> ---------------------------------
> Shape Yahoo! in your own image.  Join our Network
> Research Panel today!



       
____________________________________________________________________________________
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php

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