Building Struts Apps with Ant and XDoclet

This chapter introduces Struts and shows how to use XDoclet to cut down on the work needed to use the framework. Struts, produced under Apache Jakarta, is probably the most well-known of the Web frameworks available today. In fact, entire tutorials have been written on using Struts. Our goal in this chapter is to give you an introduction to using Struts without XDoclet in order to show the amount of work necessary to use the framework, and then we'll show how XDoclet can help with the situation. We will use an example registration system to illustrate the concepts.

Brief Introduction to Struts

As mentioned above, there are entire tutorials written on the topic of Struts, so this section will be a short introduction to the major components of the system. Following is a flow diagram of what occurs within the Struts framework.

Java Click To expand

As you can see from this diagram, the entire process starts with a home page of sorts that presents the user with links or HTML forms to be filled out. In our example later in the tutorial, we will be presenting the user with a form to register with a Web app. When the user clicks the link or the Submit button, the Struts ActionServlet will be invoked. This servlet is designed to take the URL specified in the action attribute of the HTML form or the link URL and determine an action to perform. The action is defined in a configuration file along with the Action class, action JavaBean, and the response HTML pages. The Action class is defined around the Action baseclass, and the form data is defined around the ActionForm. The HTML response pages are typically written in JSP.