Wednesday, May 23, 2018

Why ActionServlet is Singleton in struts framework?

Leave a Comment
org.apache.struts.action.ActionServlet in the web.xml configuration file must define ActionServlet is Singleton in struts framework and as ActionServlet provided by the struts Framework is a built-in servlet. ActionServlet nothing but a controller.



It has the following inbuilt design patterns.

  • Singleton design pattern.
  • FrontController
  • ApplicationController
  • MVC
  • Data Transfer object/value object
  • Inversion of control/Dependency injection

ActionServlet take the multiple request but it creates single instance for that requests by using singleton design pattern.
Few servers likes weblogic violates single instance multiple threads principle of servlet programming.That means these servers that will create more than once object for a class in special situation. see here

To avoid this type of situations & to follow servlet specifications, struts framework software developers have made built-in servlet called ActionServlet.

Note:

1. According to MVC principles, there should be only one servlet acting as controller and this servlet should have only one object.

2. Both the approaches have advantages & disadvantages :)
org.apache.struts.action.ActionServlet in the web.xml configuration file must defined as

ActionServlet provided by the struts Framework is a built-in servlet. ActionServlet nothing but a controller.It has the following inbuilt design patterns.

  • Singleton design pattern.
  • FrontController
  • Application Controller
  • MVC
  • Data Transfer object/value object
  • Inversion of control/Dependency injection


ActionServlet take the multiple request but it creates single instance for that requests by using singleton design pattern.
Few servers likes weblogic violates single instance multiple threads principle of servlet programming.That means these servers that will create more than once object for a class in special situation. see hereTo avoid this type of situations & to follow servlet specifications, struts framework software developers have made built-in servlet called ActionServlet.
Note:

  • According to MVC principles, there should be only one servlet acting as controller and this servlet should have only one object.
  • Both the approaches have advantages & disadvantages
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment