struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cakalic, James P." <>
Subject RE: Member variables in Actions
Date Wed, 21 Nov 2001 20:02:30 GMT
Quoting from the Struts User's Guide:

"The controller servlet creates only one instance of your Action class, and
uses it for all requests. Thus, you need to code your Action class so that
it operates correctly in a multi-threaded environment, just as you must code
a servlet's service method safely.

The most important principle that aids in thread-safe coding is to use only
local variables, not instance variables, in your Action class. Local
variables are created on a stack that is assigned (by your JVM) to each
thread request, so there is no need to worry about sharing them."

Best regards,
Jim Cakalic

> -----Original Message-----
> From: Dave J Dandeneau []
> Sent: Wednesday, November 21, 2001 1:49 PM
> To: Struts Users Mailing List
> Subject: Member variables in Actions
> Is there any reason that you would / wouldn't want to put member
> variables in an action? I know that using member variables in some
> servlet containers can sometimes slow things down. I don't 
> know how the
> actions are pooled / instantiated, and what affect this might have on
> the performance.  
> Thanks,
> Dave Dandeneau

<font size="1">Confidentiality Warning:  This e-mail contains information intended only
for the use of the individual or entity named above.  If the reader of this e-mail is not
the intended recipient or the employee or agent responsible for delivering it to the intended
recipient, any dissemination, publication or copying of this e-mail is strictly prohibited.
The sender does not accept any responsibility for any loss, disruption or damage to your data
or computer system that may occur while using data contained in, or transmitted with, this
e-mail.   If you have received this e-mail in error, please immediately notify us by return
e-mail.  Thank you.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message