Introduction:
This chapter will introduce steps to create struts 2 web application in detail. These steps are to be followed for every web application that we create in this tutorial.
Steps for creating Web Application:
Start NetBeans IDE 8.0.1(this is my installed version) and click on New Project.
Select the first option (i.e. Web Application). (Note : the second option is to be selected when you already have a developed project and you want to add some extra features to it. And the third option creates a Web Application without any framework, which is not useful t us presently).
Then click on next and give your project a title. The default title is normally set to “Web Application 1” and it increments so on and so forth accordingly.
The default saving location of your project is in Users -> My Documents folder. It is a good habit to save the projects in Drives other then C Drive.
Click on next and select the required server. The default server is Glassfish server. For fast server startup – shutdown as well as fast application access and run, it is advisable to use Apache Tomcat server. The version of Apache should be greater than 7.0.
Then click on next and select the framework you want to use. The current available options are:
Java Server Faces
Spring MVC
Hibernate
Struts 1.3
Struts 2
As Struts 2 is option is available (before installing struts 2 plugin, this option was disabled), select it and click on finish.
Following can be seen after successful creation of Web application.
You have been given following as a part of directory structure of web application:
Web Application 1
Web Pages
Meta – INF
Context.xml
Web – INF
Web.xml
Example
HelloWorld.jsp
Source Packages
Default package
Example.xml
Struts.xml
Example
HelloWorld.java
Package.properties
Package_es.properties
Libraries
All struts libraries
Configuration Files
MANIFEST.MF
Context.xml
Struts.xml
Web-fragment.xml
Web.xml
These are the common steps to be followed for creating web application. The steps beyond these may vary as per programs requirement.