This week's book giveaway is in the JavaScript forum.
We're giving away four copies of JavaScript Promises Essentials and have Rami Sarieddine on-line!
See this thread for details.
The moose likes Struts and the fly likes Setting HttpSession Attribute Not Working (Struts) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Setting HttpSession Attribute Not Working (Struts)" Watch "Setting HttpSession Attribute Not Working (Struts)" New topic
Author

Setting HttpSession Attribute Not Working (Struts)

Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
Hello all:

I am trying to create a simple login action for my website.
I have a login.jsp page that finds the users credentials, and if valid,
saves the users object in the HttpSession.

Here is my code for the login action:


And the corresponding ActionMapping in my struts-config.xml:


And the corresponding form-bean declaration:


This is the many attempts to try to retrieve the "user" object:


I always seem to get that the attribute,"user", is never set, therefore not being able to be retrieved.

Can anyone help me?

Thanks

Zak
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Try this, maybe it works.


Leandro Melo
SCJP 1.4, SCWCD 1.4
Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
I just tried that, and it does NOT work.
Thanks

Zak
Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
I have made sure that my object was being saved.
I successfully retrieved it inside another Action
that my application executed.

Is there anything wrong with my .jsp page?

Thanks

Zak
Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
Please help.
Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
CODE] <logic: present name="user" scope="session">This attribute is here.</logic: present>[ [/CODE]

It does work. I did not see the change from 'parameter' to 'name'.
A million thanks.

Zak
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
How does the code (the one inside logic tag) look like after processing (from the browser)?

Have you make sure you included the struts logic tag library?

Also, what kind of object is user? Are you trying to retrieve the property correctly?
[ July 26, 2004: Message edited by: Leandro Melo ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting HttpSession Attribute Not Working (Struts)