Struts-framework

Now, i assume you got some idea about MVC 2 design pattern.
like other MVC framework, Struts also follow the MVC architecture.
  
Apache Struts is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model–view–controller (MVC) architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in May, 2000.

What is the Flow of Struts??

Before starting the flow of Struts, lets have a look on same basic terminology and class associated with Struts.

ActionServlet :

The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In the the Jakarta Struts Framework this class plays the role of controller. All the requests to the server goes through the controller. Controller is responsible for handling all the requests.

ActionForm :
The controller ( ActionServlet )  intercepts every client request and populates an ActionForm from the HTTP request parameters. ActionForm is a normal JavaBeans class. It has several attributes corresponding to the HTTP request parameters and getter, setter methods for those attributes.
You have to create your own ActionForm for every HTTP request handled through the Struts
framework by extending the org.apache.struts.action.ActionForm class.


Action :


An Action class in the struts application extends Struts 'org.apache.struts.action.Action" Class.
An Action is an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request.
Actions exists between the Model and View of an application.


To use the Action, we need to Subclass and overwrite the execute() method. and your bussiness login in execute() method. 

ActionForward :


An ActionForward is a return type of the execute method which is used by the Struts Framework to forward the request to the JSP as per the value of the returned ActionForward object.
An ActionForward represents a destination to which the controller, RequestProcessor, might be directed to perform a RequestDispatcher.forward or HttpServletResponse.sendRedirect to, as a result of processing activities of an Action class.

ActionMapping :
There is a class called ActionMapping in org.apache.struts.action package.
ActionMapping is the class that does what its name says – it holds the mapping
between a URL and Action.

 


 

 


<<Previous>>

No comments:

Post a Comment