is Action Servlet is designed as a Singleton class ?why?
Joined: Dec 07, 2006
Hi, Please answer this very urgent.
is Action Servlet is designed as a Singleton class ?if so why?
Thanks in advance.......
Joined: Feb 15, 2005
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.