Struts is a framework to develop the Java technology-based software using MVC architecture. Struts is called an open-source framework which extends the Java Servlet API and employs a model, view, controller (MVC) controller architecture. It highlights maintainable, extensible, and flexible web applications that depend on standard technologies like JSP pages, JavaBeans, resource bundles and XML.
When we use struts the framework will give us the controller servlet, ActionServlet, which is defined in the struts that are libraries which include in the IDE and which is automatically registered in the web.xml deployment descriptor. The controller servlet uses a struts-config.xml file to map incoming requests to struts Action objects and instantiate any ActionForm objects connected with an temporarily store form of data. This action object will contain requests by using the execute method while making use of any data that is stored in the form of bean. Once the Action object processes a request, it stores any new data and forwards the result to the appropriate view.
Developing a struts application will be similar to developing any kind of web application in NetBeans IDE. We complement our web development toolkit by taking advantage of the struts support provided by the IDE. For example, we use templates in the IDE to create struts Action objects and ActionForm beans. This IDE automatically registers these classes in the struts-config.xml file and let’s extend this file and lets us extend this file will be easily by using menu items in the source editor’s right-click menu. Many web applications will be using the JSP pages for the view. Struts will provide custom tag libraries which will facilitate interaction with the HTML forms.
How to set up the struts Application?
A struts application will be nothing more than a normal web application accompanied by the struts libraries and also configuration files. We can create a struts application as we create any other web application in IDE by using the new application wizard with the additional step indicating that we want the struts libraries and configuration files that to be included in our application.
- Firstly we have to choose file -> New Project from the menu. Select the Java Web in the list of categories and then select web application in the list of projects. Click next
- The Name and Location panel may enter MystrutsApp for project Name and click next
- In the server and settings panel, select the server to which we want to deploy the application. Here only servers which are registered with the IDE will be listed.
- Select struts in the Frameworks panel.
Struts option will display in the frameworks panel of the new web application wizard. This wizard will display an option of configuration
- ActionServlet Name- The following name of the struts action servlet will be used in the application. The web .xml deployment descriptor has an entry for the action servlet and also mentions the appropriate struts specific parameters like as path to the servlet class within the struts library and also to the struts-config.xml configuration file within the application
- Action URL Pattern- That will specify the pattern of incoming requests which are mapped to the struts action controller. This generates a mapping entry in the deployment descriptor. Only the *.do pattern is mapped.
- Application resource- We specify the resource bundle which will be used in the struts-config.xml file for localising messages. This will be as com.myapp.struts.ApplicationResource.
- Add Struts TLDs- We generate tag library descriptors for the struts tag libraries. A tag library descriptor is an XML document which contains additional information about a whole as each individual tag. We can notify online as URIs rather than local TLD files.
- Click finish. The IDE will create the project metadata, such as the Ant build script. Our web application in addition has all of the struts libraries on its classpath It vl be included in the package it with when we build the project.
Questions
- What is struts? Explain its features
- How to set up the Struts?
One Response
1.What is struts? Explain its features
Struts is an open source framework that extends the Java Servlet API and employs a Model, View, Controller (MVC) architecture. It enables to create maintainable, extensible, and flexible web applications based on standard technologies.
2.How to set up the Struts?
1. choose file -> New Project from the menu. Select the Java Web in the list of categories and then select web application in the list of projects. Click next
2.The Name and Location panel may enter MystrutsApp for project Name and click next
3.In the server and settings panel, select the server to which we want to deploy the application. Here only servers which are registered with the IDE will be listed.
4.Select struts in the Frameworks panel.