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 be return by calling the findForward() method with ActionMapping reference and hence control will transfer to the caller i.e RequestProcessor.

Description about execute()

public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, 
 HttpServletResponse response)throws Exception { 

    return mapping.findForward(result);

}

Caller of the execute() is RequestProcessor and return will also go the RequestProcessor. So by this we can confirm that after calling process() method by the RequestProcessor , now its the responsibility of the RespectProcessor to handle all the request of the client by calling execute() method.

execute() method is parametrized with ActionMapping , ActionForm , HttpServletRequest, HttpServletResponse reference.

Why ActionMapping ?

It is because findForward() method is implemented in the  ActionMapping class only and return ActionForward object.

Why ActionForm ?

It is because because before control comes to Action class it check the form bean class and hence its object has all the required value of the HTML form elements ( text field, checkboxes, drop down etc ).

Why HttpServletRequest ?

It is because to handle and process the request by the clients.

Why HttpServletResponse ?

It is because to send the response to the client after processing the request.

Note: Each Action class must be mapped in the struts-config file within action-mapping tag and hence need to also configure its from bean class.



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
  • 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
  • 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
  • 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 to configure Action class Action class must be configured in the struts-config.xml file so that container must have the information for which action it has to forward to which Action class. That's is why we are configuring the Action classes. For e… 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