File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Safety in Action Servlets

 
Jason Stull
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Struts People,
Any specific pointers on how to make access to the HTTPSession, specifically properties in the session, thread-safe? Should synchronization be used whenever accessing session properties? Is it enough to limit access to session variables just from within the Action Servlet's perform method?
-j
 
Srikanth Shenoy
author
Ranch Hand
Posts: 184
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTTP Session variables are your own. They just belong to you no one else.
The question of thread safety doesnt arise
 
Jason Stull
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Srikanth for your reply. I've heard good things about your Struts book. I guess I'm refering to the Struts API docs for the Action class:
Action
Where it states, "Access to other resources (JavaBeans, session variables, etc.) MUST be synchronized if those resources require protection. (Generally, however, resource classes should be designed to provide their own protection where necessary."
Does this just refer to resources used by more than one session, Singletons, etc?
 
Srikanth Shenoy
author
Ranch Hand
Posts: 184
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,
I had never looked at it before. But it definitely sounds vague.
I am not exactly sure what they were trying to convey.
I would take a guess: They are probably referring to shared resources, and, as you said, singleton loosely belongs to shared resource category.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic