Installing and Configuring Struts


Although all Struts binaries required by the sample GreaterCause application are made available with the GreaterCause download, you can refer to http://jakarta.apache.org/struts/userGuide/installation.html to find out more about Struts installation and configuration. The binaries provided with the GreaterCause download pertain to Struts 1.1 beta release 2, which was used to test the application.

If you want to install the most current binaries, you will need the following from the Struts binary distribution for testing the sample GreaterCause application:

  • lib/commons-*.jar These JAR files contain packages from the Jakarta Commons project that are used by the Struts framework. Copy these files into the WEB-INF/lib directory of the GreaterCause application.

  • lib/struts.jar This JAR file contains all classes used by the framework. Copy these files into the WEB-INF/lib directory of the GreaterCause application.

  • lib/struts-*.tld Copy these tag library descriptor files into the WEB-INF directory of your web application.

Chapters 4 and 5 explain the deployment descriptor (web.xml) configured for using the Struts controller servlet. The following Struts-related tag library declarations are included in the web.xml deployment descriptor:

 <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> 

These tag libraries are referenced in the GreaterCause JSPs using the following declarations:

 <%@ 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" %> 

For modifying the characteristics of GreaterCause application, follow the instructions provided in Chapter 4 and 5 for creating/modifying entries in the WEB-INF/struts-config.xml file.

When compiling request handlers, form beans, or any other class that makes use of Struts components, include the struts.jar and commons-*.jar files in the CLASSPATH.

Configuring the Struts Validator

The sample application makes use of the Validator plug-in. The Validator services are injected into the Struts framework using the following declaration in the struts-config.xml file:

 <plug-in className="org.apache.struts.validator.ValidatorPlugIn">    <set-property property="pathnames"       value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> </plug-in> 

The following two files are configured in the GreaterCause web application's WEB-INF directory:

  • Validator-rules.xml This file contains the basic validators that are packaged with the framework.

  • Validation.xml In this configuration file, we specify the validations associated with the form bean properties.

A detailed discussion of Validator is available at http://home.earthlink.net/~dwinterfeldt/overview.html.




Practical J2ee Application Architecture
Practical J2EE Application Architecture
ISBN: 0072227117
EAN: 2147483647
Year: 2003
Pages: 111
Authors: Nadir Gulzar

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net