Instance variables in your actions classes are not thread-safe. :)

Why not call getMySession from inside execute() and store it in a local variable?

> -----Original Message-----
> From: Johnny Rask [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 01, 2003 7:03 PM
> To: [EMAIL PROTECTED]
> Subject: Base Action Class
> 
> 
> Hello,
>  I have created a BaseAction class which extends
> Action. I in turn extend this BaseAction class for my
> specific needs (for example a user registration
> action). Inside my BaseAction I was thinking of adding
> an instance variable named mySession of type MySession
> which is essentially a container(java bean) of
> different "things" and is stored in the session under
> a keyed name (MY_SESSION). Then adding a
> getMySession() method in BaseAction to retrieve this
> session scoped variable from the HttpSession. 
> 
> Basically I want a uniform way to access this
> container class from any of the Action classes methods
> that extend BaseAction.  Are there any downfalls to
> this concept? I thought I read a previous message
> somewhere saying never to have instance variables in
> your action classes because it is not thread safe, is
> this true?
> 
> Side note I am using an HttpSessionListener to put a
> MySession instance into the HttpSession when a new one
> is created.
> 
> Thanks,
> Gator
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online, calculators, forms, and more
> http://platinum.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to