Web application development was once simple there was a HTML and browser. There was no dynamic or business data, so no business application. But this simplicity lasted for small duration. Today we are forced to do many complicated application development.
This chapter assumes that you have the knowledge of JSP, Servlet, custom tag libraries and XML
What is a struts?
Struts form the Jakarta project is a development framework for java servlet application based upon the model-view-controller (MVC)
The aim of MVC architecture is to separate the business logic and data of the application from the presentation of data to the user. Following is the small description of each of the components in MVC architecture:>
Model : The model represents the data of an application. Anything that an application will persist becomes a part of model. The model also defines the way of accessing this data ( the business logic of application) for manipulation. It knows nothing about the way the data will be displayed by the application. It just provides service to access the data and modify it.
View : The view represents the presentation of the application. The view queries the model for its content and renders it. T
he way the model will be rendered is defined by the view.The view is not dependent on data or application logic changes and remains same even if
the business logic undergoes modification.
Controller : All the user requests to the application go through the controller. The controller intercepts the requests from view and passes it to the model for appropriate action. Based on the result of the action on data, the controller directs the user to the subsequent view
STRUTS is a comprised of controller servelt, beans and others java classes, configuration files, and tag libraries. This means when you download struts you will have the following
A controller for your application
A collection of java beans and other helper classes that you use in the model part of your application.
A collection of tag libraries used in your jsp-pages.
Wit all these together struts uses a set of configuration files. Together this gives you the skeleton that you can use to struts to your application
A struts has been designed to give you modularity and looses coupling in your application. If yours building a simple, small application you might find it complicated to have to create and handle so may files. You might even be tempted to put all together to put all your code in a single jsp-file. But my advice is “don’t do it”. I know you can build single page application faster using only one jsp page. But if were talking ballot more complex application, the extra effort put in by using modular framework will soon be rewarded
Downloading and installing struts
Struts is downloaded form the JAKARATA PROJECT at http://jakarta.apache.org/struts to simplest way to install struts is to copy a small struts application, packed in struts-blank.war, form the downloaded file to your servlet container. if you are using TOMCAT and many other servlet containers you place the war file in the “webapps” folder and you now only need to restart your server and you will have struts-blank running. on tomcat you can check your installation with this URL: http://localhost:8080/struts-blank/index.jsp