• The special web resource in the web application that is capable of trapping all the request coming to other web resource of web app by having common and global pre request processing logic is called front controller
  • A servlet or jsp of web app can be made as front controller by configuring them with extension match or directory match url pattern
  • Classic web app means the regular web application that is developed by using servlet jsp and without using any framework s/w
  • The front controller web resources contains common and global pre request processing logic like user authentication and authorization logic
  • In struts app action servlet is front controller servlet. So it should be configured in web.xml file by having either extension match or directly match url pattern by programmer
FAQ
What is need of making action servlet as front controller servlet?
The entire request coming to struts app will target to execute logics place in action classes since action classes are java classes and there are not servlets. So they can’t take http request given by browser directly. So that we need a special servlet/jsp based web resource to trap the entire http request coming to struts app and to pass those request to appropriate action classes
If special servlet is action servlet and this has to be made as front controller to trap all the http request coming to action classes of struts app

Note
A java class of web app can’t take http request directly from the browser. It has to take that request through a servlet/ jsp web resource
  • Even though ActionServlet is built in servlet but configuring that servlet in web.xml as front controller servlet by having extension match or directly match url pattern is the responsibility of programmer
<web-app>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionSerlvet</serlvt-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/mycfg.xml</param-value>
</init-param>//struts configuration-file name and location of configuration
<load-on-startup>2</load-on-startup>
</servlet>
</servlet-mapping>
</servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
  • Servlet gathers non technical input values from end user as request parameter values. Servlet gather technical input values from programmer as init parameter, context parameter values in web.xml file. Struts configuration file name and location are technical input values fro action servlet. So, it givens a fixed init parameter name called config for programmers to pass name and location of struts configuration file as technical input value to action servlet
  • If this init parameter (config) the action servlet looks to take /WEB-INF/struts-config.xml file as default struts configuration file
  • Since action servlet is also controller of struts based web app which is according to Mvc architecture. so the action servlet has got the ability to collect the result from action class business class execution
  • Due to this even though action servlet is configure as front controller it is also acting as controller of struts app and taking the result given by action class