Struts Architecture
Java

Overview of Struts Architecture

Programmingempire

In this article, I will discuss struts architecture. Basically, a Java-based dynamic web application comprises servlets and JSP files. While servlet API along with JSP is sufficient to create a web application. But still, application development becomes easier with the use of frameworks. So, the use of a framework reduces both development time and effort. In fact, the use of struts makes you more productive and the application becomes more manageable.

Since the struts framework is developed over the Servlet API, so whatever we can do with struts, that we can also achieve with servlets only. Basically, the struts framework is a Model View Controller (MVC) architecture. While the responsibility of the model is to provide the business logic and to deal with the database, the view interacts with the user. Hence, the view comprises JSP files containing forms and the output. Besides, the controller is an interface between the view and model. It receives the requests and maps them to an appropriate view. The following figure represents the architecture of struts.

The architecture of Struts

At first, the user interacts with the application using a form that might be a JSP. As soon as, the request is received, the controller takes appropriate action. Indeed, the ActionServlet is the controller that on receiving the request decides to which model, the request should be passed. For this purpose, it makes use of a configuration file known as struts-config.xml. In general, this configuration file associates a view to a model. Accordingly, the controller bundles the request parameters in a JavaBean class. It also determines which class will process that request. Further, the corresponding model class interacts with the database.

Once, the request processing is over, the controller receives an ActionForward from the Action class. Finally, the controller provides the appropriate view to the user.

Struts Architecture
Struts Architecture

Further Reading

programmingempire

You may also like...