The Struts binary distribution needs three other software packages installed to operate. You may already have these installed on your system. To build Struts from source you may need to acquire and install several others. The complete list is as follows:
<style>
command.
javax.sql.DataSource
, so it
requires the API classes to be compiled. They can be
downloaded from
http://java.sun.com/products/jdbc/download.html
.
Unpack the Struts binary distribution into a convenient directory. (If you build Struts from the source distribution , the result of the build will already be an unpacked binary distribution for you). The distribution consists of the following contents:
WEB-INF/lib
directory of your web application.
WARNING
- If you are going to be hosting multiple Struts
based applications on the same servlet container, you will
be tempted
to place the
struts.jar
file into the shared repository
supported by your container. Be advised that this will
like cause you
to encounter ClassNotFoundException problems unless
all
of
your application classes are stored in the shared
repository.
WEB-INF
directory of your web application.
lib/struts.jar
from the Struts distribution
into the
WEB-INF/lib
directory of your web application.
lib/struts*.tld
from the Struts distribution into the
WEB-INF
directory
of your web application.
WEB-INF/web.xml
file for your web application
to include a
<servlet>
element to define the
controller servlet, and a
<servlet-mapping>
element
to establish which request URIs are mapped to this
servlet. Use the
WEB-INF/web.xml
file from the Struts example application
for a detailed example of the required syntax.
WEB-INF/web.xml
file of your web application
to include the following tag library declarations:
<taglib> <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri> <taglib-location>/WEB-INF/struts-template.tld</taglib-location> </taglib>
WEB-INF/struts-config.xml
that defines the
action mappings and other characteristics of your specific
application.
You can use the
struts-config.xml
file from the Struts
example application for a detailed example of the required
syntax.
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
struts.jar
file (copied earlier) on the
CLASSPATH that is submitted to the compiler.
struts.jar
to the classpath of your servlet container in an
attempt to avoid placing it in the
/WEB-INF/lib
directory of
each individual web app! Doing so will cause problems with
ClassNotFoundException
exceptions.
For most containers, you need only to:
/webapp
directory to your
containers
webapps
directory.
To build Struts, you will need to customize the build process to the details of your development environment as follows:
build.properties
(in the top-level directory of the
distribution) to identify the location of external
components
that Struts depends on.
build.properties
file included with the
source distribution. However, there is an example file
named
build.properties.example
that you can copy to
build.properties
and then customize.
build.properties
are:
deploy.catalina
target).
deploy.tomcat
target).
deploy.catalina
target).
build.properties
file, since it will be different for
each individual developer.
build.properties
file as described above. Then, type:
ant dist
This command will create a binary distribution of Struts, in a
directory named
dist
(relative to where you
are compiling from). This directory contains an exact replica
of the
files included in a binary distribution of Struts, as
described
in the
preceding section
.