[ Team LiB ] Previous Section Next Section

Setting Up Struts

After you have downloaded Struts, the first thing you need to do is make sure your webapp is set up to use Struts. To do this, you need to make sure the struts.jar is in your classpath. Typically, you would copy the struts.jar file under your WEB-INF\lib directory that will become part of the JAR file you will use to deploy your Web application.

The various other Struts JAR files that start with common*.jar should also be copied with the struts.jar file. All the Struts properties files will be under the WEB-INF directory.

If you have multiple Struts applications, you can copy these JAR files to the shared\lib or common\lib directories beneath your Tomcat installation home. Doing this allows all your webapps to use the same version of Struts. There are many arguments for and against this approach, but you do not need to worry about these for now.

The Struts download also comes with an empty Struts application called struts-blank.war. You can deploy this Web application to the webapps directory of Tomcat, and you can use it as a starting point for building a Struts application. Table 21.1 explains the directory structure of a Struts application.

Table 21.1. Directory Structure of a Struts Application

File or Directory



Meta information.


You should put all your Java classes here.


This file contains all the messages,


text, and error messages. Similar concept to internationalization.


This is the Struts library.


The Struts tag libraries.


Struts configuration file.


Standard J2EE Web app configuration file.


Place all your jsp/html pages in the root of the Web app directory.

You now know how to create and deploy a simple Struts-based application. Now let's talk about JavaServer Faces (JSF) and how it relates to Struts.

    [ Team LiB ] Previous Section Next Section