All the Request by the client are get processed by the ActionServlet only then get forwarded to the Request Processor.
ActionServlet is a single Servlet designed by the Apache using Front Controller Design Pattern. It follows the life cycle of the Servlet  by calling init() method then doPost() or doGet() and finally destroy().

Internal Implementation of the ActionServlet
  
public class ActionServlet extends HttpServlet {

   RequestProcessor rp = null;

   public void init(ServletConfig sc){

init() method is parameterized with ServletConfig object which is used to collect the data mentioned in the xml file under the init-param tag.

   String file_name= sc.getInitParameter("config");

Hence we hard-code the value " config " in the xml file because it is hard-coded in the ActionServlet class as well. And by this it will get the name of the struts-config xml file.

Start parsing or reading the data from the struts-config xml file by using the SAX Parser and store the information in the main memory.

    rp= new RequestProcessor(); 

}

After initializing the ServletConfig object RequestProcessor get initialized and store the data parsed from the struts-config file into the RequestProcessor object.

public void doPost(HttpServletRequest,HttpServletResponse) {

   rp.process(request,response);

}

or

public void doGet(HttpServletRequest,HttpServletResponse) {

   rp.process(request,response);

}

Then doPost() or doGet() method will be called by passing the request and response object and in this method a process() method will be called by the RequestProcessor object by passing HttpServletRequest and HttpServletResponse so that the request will be processed by the RequestProcessor object only.


public void destroy(){

   }
}

Finally destroy method will be called.

Note: Once the ActionServlet class is initialized then it will be eligible to handle any request with the url-pattern mentioned as *.do or any thing . 

This is the reason why we are writhing like *.do means any request will be handled by the ActionServlet only. This is also called as Front Controller Design Pattern that means a single Servlet is responsible to handle all the incoming request. 



Related Posts:

  • Configuring the ActionServlet in web.xml As ActionServlet is simple Servlet class only but designed using the Front Controller Design Patern so it must be configured in the web.xml file at the container itself only, so that every request must be followed by Action… Read More
  • What Happen after Container start-up in Struts based Application Following task are performed at the Container start-up in Struts based Application. They are : 1. Container make sure about the web configuration file i.e web.xml whether is available or not. 2. If not available then C… Read More
  • First Struts 1 Example Using Eclipse Steps to follow for developing Struts Application using Eclipse :- We must have to follow some of the basic steps to develop any struts application using the Eclipse IDE. 1. Create Dynamic Web Project. 2. Copy all the… Read More
  • Implementing execute() with HTTP request in Struts We can write our own Action class using Struts framework but need to extends Action class of org.apache.struts.action package and need to override execute() method which return the ActionForward class object and which must… Read More
  • How Request Handled By ActionServlet ? All the Request by the client are get processed by the ActionServlet only then get forwarded to the Request Processor. ActionServlet is a single Servlet designed by the Apache using Front Controller Design Pattern. It fo… Read More

0 comments:

Post a Comment

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

201978

Online Members

Live Traffic