15 June, 2012

J2EE: What is a Struts in our Life ? Struts.

We need to  our life with a easy & smooth track. Now-a-days our technology runs above of the sky with new vision. But , can we feel struts is one of the necessary part of software development , basically on the footprint of JAVA/J2EE.

When I was new to software development ( java/j2ee) at that time struts was new to me & I always afraid about what is that. But, after the span of time slowly slowly deeply I rushed into that struts garden.

Struts framework is an open-source framework for developing the web applications in Java EE, based on MVC-2 architecture. It uses and extends the Java Servlet API. Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java. The term Framework, is way we find to easy developing environment with all possible features for that environment. Its a complete 3rd party(in other way).

Struts components can be categorize into Model, View and Controller:
  • Model: Components like business logic /business processes and data are the part of model.
  • View: HTML, JSP are the view components.
  • Controller: Action Servlet of Struts is part of Controller components which works as front controller to handle all the requests.
Also Struts is a set of cooperating classes, servlets, and JSP tags that make up a reusable MVC 2 design.
  • JavaBeans components for managing application state and behavior.
  • Event-driven development (via listeners as in traditional GUI development).
  • Pages that represent MVC-style views; pages reference view roots via the JSF component tree.

But the major role in struts is ActionServlet. ActionServlet is a simple servlet which is the backbone of all Struts applications. It is the main Controller component that handles client requests and determines which Action will process each received request. It serves as an Action factory – creating specific Action classes based on user’s request.It has following roles:
  • Process user requests
  • Determine what the user is trying to achieve according to the request
  • Pull data from the model (if necessary) to be given to the appropriate view,
  • Select the proper view to respond to the user
  • Delegates most of this grunt work to Action classes
  • Is responsible for initialization and clean-up of resources

Except ActionServlet , there is one ActionForm, which may lead you to represent data(Usable component) . ActionForm is javabean which represents the form inputs containing the request parameters from the View referencing the Action bean.It has  2 major methods validate() and reset(). These methods are used by struts framework.

Also ActionMapping, ActionForward,Dispatch Action are play major roles in struts. Follow other reads/posts.

To make your application faster & easy , I follow struts.

No comments:

Post a Comment