You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Pat <cp...@yahoo.com> on 2005/10/11 23:31:03 UTC

findforward w/session objects

Hello
When I use the code below the Action "playThis" claims
the file attribute is null.  It is not unless I am
loosing the session on the findforward.  How can I
store a value in the session and forward to an Action?
 The first line of the "playThis action is String file
= (String) request.getAttribute("file"); so why is
attribute null?  Any enlightment welcomed.

    System.out.println("file= "+temp);
    session.setAttribute("file", temp);
    return actionMapping.findForward("playThis");


	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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


Re: findforward w/session objects

Posted by Leon Rosenberg <ro...@googlemail.com>.
session.setAttribute("file", temp);
vs.
request.getAttribute("file");

you know that request and session are different scopes?
change the second line to request.getSession().getAttribute("file");

regards
leon

On 10/11/05, Chris Pat <cp...@yahoo.com> wrote:
> Hello
> When I use the code below the Action "playThis" claims
> the file attribute is null.  It is not unless I am
> loosing the session on the findforward.  How can I
> store a value in the session and forward to an Action?
>  The first line of the "playThis action is String file
> = (String) request.getAttribute("file"); so why is
> attribute null?  Any enlightment welcomed.
>
>     System.out.println("file= "+temp);
>     session.setAttribute("file", temp);
>     return actionMapping.findForward("playThis");
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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


Re: findforward w/session objects

Posted by Chris Pat <cp...@yahoo.com>.
Hi Geeta
Thank you.  Even though it is a major point, I am
getting killed by syntatic problems.  I know the
sophisticated issues but the "blocking & tackling" is
my present downfall.  I feel like I am the teacher and
student in the Jaime Escalante story, grin.

--- gramani@intellicare.com wrote:

> Chris Pat <cp...@yahoo.com> wrote on 10/11/2005
> 05:31:03 PM:
> 
> > Hello
> > When I use the code below the Action "playThis"
> claims
> > the file attribute is null.  It is not unless I am
> > loosing the session on the findforward.  How can I
> > store a value in the session and forward to an
> Action?
> >  The first line of the "playThis action is String
> file
> > = (String) request.getAttribute("file"); so why is
> > attribute null?  Any enlightment welcomed.
> 
> Chris, here's your problem: You are storing temp as
> a session attribute, 
> but retrieving it as a request sttribute. So replace
> (String) 
> request.getAttribute("file") with (String)
> session.getAttribute("file"), 
> and you should be ok..
> 
> > 
> >     System.out.println("file= "+temp);
> >     session.setAttribute("file", temp);
> >     return actionMapping.findForward("playThis");
> 
> Regards,
> Geeta
>  



		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs

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


Re: findforward w/session objects

Posted by gr...@intellicare.com.
Chris Pat <cp...@yahoo.com> wrote on 10/12/2005 11:29:41 AM:

> Hi Geeta, et. al
> I typed too soon.  I am still getting a servlet error

What error are you getting? That String file below is null? Maybe the 
error is differnet from what you think it is..?

If not, this is strange. I have set countless session vars and forwarded 
to different actions and got the variables back fine, so try the following 
things:

1. Clean out your work directory, do a full rebuild, restart tomcat and 
try again.
2. Check and make sure you are forwarding to something which is still in 
the same web context. (recheck the struts-config.xml).

> even with this modified code and not getting a the
> println produced. 
> playThis action:
> 
>  HttpSession session = request.getSession(false);
>     if (session == null)
>       System.out.println("null session");
>     String file =
> (String)session.getAttribute("file");
> 
> I confirmed that the file object was in the session
> before the actionMapping.findForward("playThis") and
> with the getSession(false) I am not creating the
> session and should be only retrieving the session I
> confirmed existed and was populated before the
> findForward.  What am I obscenely not recognizing
> here? Many thanks for any enlightenment.

Geeta
 

Re: findforward w/session objects

Posted by Chris Pat <cp...@yahoo.com>.
Hi Geeta, et. al
I typed too soon.  I am still getting a servlet error
even with this modified code and not getting a the
println produced.  
playThis action:

 HttpSession session = request.getSession(false);
    if (session == null)
      System.out.println("null session");
    String file =
(String)session.getAttribute("file");

I confirmed that the file object was in the session
before the actionMapping.findForward("playThis") and
with the getSession(false) I am not creating the
session and should be only retrieving the session I
confirmed existed and was populated before the
findForward.  What am I obscenely not recognizing
here? Many thanks for any enlightenment.


--- gramani@intellicare.com wrote:

> Chris Pat <cp...@yahoo.com> wrote on 10/11/2005
> 05:31:03 PM:
> 
> > Hello
> > When I use the code below the Action "playThis"
> claims
> > the file attribute is null.  It is not unless I am
> > loosing the session on the findforward.  How can I
> > store a value in the session and forward to an
> Action?
> >  The first line of the "playThis action is String
> file
> > = (String) request.getAttribute("file"); so why is
> > attribute null?  Any enlightment welcomed.
> 
> Chris, here's your problem: You are storing temp as
> a session attribute, 
> but retrieving it as a request sttribute. So replace
> (String) 
> request.getAttribute("file") with (String)
> session.getAttribute("file"), 
> and you should be ok..
> 
> > 
> >     System.out.println("file= "+temp);
> >     session.setAttribute("file", temp);
> >     return actionMapping.findForward("playThis");
> 
> Regards,
> Geeta
>  




		
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

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


Re: findforward w/session objects

Posted by gr...@intellicare.com.
Chris Pat <cp...@yahoo.com> wrote on 10/11/2005 05:31:03 PM:

> Hello
> When I use the code below the Action "playThis" claims
> the file attribute is null.  It is not unless I am
> loosing the session on the findforward.  How can I
> store a value in the session and forward to an Action?
>  The first line of the "playThis action is String file
> = (String) request.getAttribute("file"); so why is
> attribute null?  Any enlightment welcomed.

Chris, here's your problem: You are storing temp as a session attribute, 
but retrieving it as a request sttribute. So replace (String) 
request.getAttribute("file") with (String) session.getAttribute("file"), 
and you should be ok..

> 
>     System.out.println("file= "+temp);
>     session.setAttribute("file", temp);
>     return actionMapping.findForward("playThis");

Regards,
Geeta