First Struts Application Using NetBeans IDE
Previous Home Next

As we know that Struts is an open source framework that extends the Java Servlet API and employs a Model, View, Controller (MVC) architecture for create flexible, maintainable, and extensible web applications based on standard technologies, such as HTML, Servlet, JSP , JavaBeans, XML and resource bundles. Here, this tutorial teach you how to build a simple MVC application that displays a index page and then returns a welcome page.

Requirement for such application:

  1. NetBeans IDE ( higher is better)
  2. Java Development Kit( JDK)
  3. Apache Tomcat version XX and GlassFish Server version V3 domain or Open source Edition XX ( or used different version Server in similar category )
  4. Struts Framework (which also include into NetBeans IDE )

Overview of the application:

In the Struts, framework provides a controller servlet, ActionServlet( in ServletClass org.apache.struts.action.ActionServlet map into web.xml), which is define in Struts library that already include in your IDE, and which is automatically registered in the web.xml deployment descriptor file. That controller servlet uses a struts-config.xml file to map incoming requests to Struts Action objects, and instantiate any ActionForm objects associated with the action to temporarily store form data. The Action object processes requests using its execute method, while making use of any data stored in the form bean. Once the Action object processes a request, it stores any new data (i.e., in the form bean, or in a separate result bean), and forwards the results to the appropriate view file like HTML or JSP. Struts also provides custom tag libraries which facilitate interaction with HTML forms. Through these library, you can easily invoke code completion and Javadoc support that may helps you to work efficiently in your project.

Now following Steps involved in the how to create a simple Struts application by using NetBeans IDE ( using IDE 6.8 with default Struts version 1.3.8):

Setting Up a Struts Application: Struts application is similar to any of web application in your IDE. Take the following Step for Develop myFirstStrutsApp by using your IDE

  1. Choose File : New Project under Categories, select Java Web under Projects, then select Web Application and click Next.
  2. After doing all the step a windows open (also display below), now put some name of your project and click next.
  3. After that add server, which install in your IDE like Apache Tomcat or Personal GlassFish V3 or similar kind of server, and click next.

  5. After that, add Struts Framework, struts TLDs (TagLibrary) and don't forget configuration( your action class config here into web.xml ) then click finish.
    • Action Servlet Name : The web.xml deployment descriptor file contains an entry for the action servlet and specifies the appropriate Struts-specific parameters, such as action and path to the servlet class within the Struts library and to the struts-config.xml configuration file within the application.
    • Action URL Pattern : This generates a mapping entry in the deployment descriptor by specifies the patterns of incoming requests which are mapped to the Struts action controller. By default, only the *.do pattern is mapped although we can used /do/* for mapping.
    • A pplication Resource : Lets you specify the resource bundle in your application which will be used in the struts-config.xml file for error and localizing messages. By default, this is store in
    • Add Struts TLDs : Used to generate tag library descriptors for the Struts tag libraries.
  6. After all above step, , your application display in your IDE( include two JSP pages, 5 different TagLibrary, web.xml, and struts-config.xml), and most important thing all struts library also include into your application in library folder.
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Comment / Feedback: