• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts session

 
Ranch Hand
Posts: 290
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am setting a few session attribute in my action class


But when I try to retrieve them in jsp file, it returns null.
If I set the scope to "session" in struts-config.xml, then it works fine.

Can some one please explain this behavior and suggest a solution

Thanks
Aryan
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are working on Session, you should use scope as session
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The jsp that you are trying to retrieve the attribute from the session in, is it in the same request where you set the session attribute?

If it is then I have no guess. If its not then the problem may be that your application server is explicitly garbage collecting your form object at the end of the request (because its in request scope), even thought the user name is still being referenced in the session. Maybe it would work if you used a clone of the username instead of the actual object in the form. I'm guessing here but a simple .clone() might fix it so it might be worth a try.
 
Aryan Khan
Ranch Hand
Posts: 290
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
funny part is it works with sun application server bundled with netbeans 6 but not with tomcat
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wonder if some application servers garbage collect request objects more thouroughly than others.
 
Aryan Khan
Ranch Hand
Posts: 290
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe... because the same application works smoothly with Glassfish application server but not tomcat 5 or 6.

Finally I settled down to use Glassfish.

Aryan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic