This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes is Action Servlet is designed as a Singleton class ?why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "is Action Servlet is designed as a Singleton class ?why?" Watch "is Action Servlet is designed as a Singleton class ?why?" New topic
Author

is Action Servlet is designed as a Singleton class ?why?

Shiva Shankar
Ranch Hand

Joined: Dec 07, 2006
Posts: 31
Hi,
Please answer this very urgent.

is Action Servlet is designed as a Singleton class ?if so why?

Thanks in advance.......
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Yes, the ActionServlet class is a singleton in the sense that there's only one per JVM. Why? Because the J2EE specification mandates that every servlet needs to work this way. It's a question of efficiency and memory conservancy. why have dozens or hundreds of instances of the same class in memory that all do the same thing? Because of this, all servlets must be coded as "thread-safe".

In a Struts application, not only is the ActionServlet a singleton, but also all your Action classes as well. You must code these classes as thread-safe also.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is Action Servlet is designed as a Singleton class ?why?
 
Similar Threads
Scheduled Servlet
Servlets
instance varibales for Singleton class ?
ActionError problems with Singleton Action Bean in Struts2
Whay action class is not singleton