Saturday, October 31, 2009

Installing JSTL without the Examples






















 Print  
 E-Mail
 
 Add
Note    Add
Bookmark
   














JSTL:
JSP Standard Tag Library Kick Start
By
Jeff Heaton

Table
of Contents
Appendix B.  Installing JSTL
and Tomcat









Installing JSTL without the
Examples


If you follow the instructions in the
previous section, you will correctly install JSTL and the book
examples. In this section, we explain how to install JSTL
apart from the book's examples. If you want to install JSTL
into a server environment, this is the procedure you
follow.


The exact directory that JSTL will install
into varies somewhat, depending on the version. In the 1.0
version, there is a jstl-1.0 directory, and in 1.0.1 it is
called standard-1.0.1. Inside this directory is a lib
directory that contains several files. Table
B.1 documents the purpose of each of these files.
































































Table B.1. The JSTL
Files

class=docEmphStrong>File


class=docEmphStrong>Purpose


c.tld


The core tag library (EL
version)


c-rt.tld


The core tag library (RT
version)


dom.jar

 

fmt.tld


The I18N tag library (EL
version)


fmt-rt.tld


The I18N tag library (RT
version)


jaxp-api.jar


Required JAR file for JSTL


jaxen-full.jar


Required JAR file for JSTL


jdbc2_0-stdext.jar


Required JAR file for JSTL


jstl.jar


Required JAR file for JSTL


sax.jar


Required JAR file for JSTL


saxpath.jar


Required JAR file for JSTL


sql.tld


Database tag library (EL
version)


sql-rt.tld


Database tag library (RT
version)


standard.jar


Required JAR file for JSTL


xalan.jar


Required JAR file for JSTL


xerxesImpl.jar


Required JAR file for JSTL


x.tld


XML tag library (EL version)


x-rt.tld


XML tag library (RT
version)


To properly install JSTL for your Web
application, you must copy these files to specific locations.
The two JAR files (standard.jar and jstl.jar) must be copied
to your Webapp's library directory. This ensures that these
files will be part of the classpath. Under the Windows
operating system, your lib directory for Tomcat will be
C:\Program Files\Apache Tomcat
4.0\webapps\ROOT\WEB-INF\lib.


You copy the tag definition files, which have
a .tld extension, to your WEB-INF directory. This is typically
a child directory of the Web root directory for your Web
application. The Web root directory is the directory that
holds all your JSP and HTML files. Under the Windows operating
system, Tomcat's Web root directory is typically
C:\Program Files\Apache Tomcat 4.0\webapps\ROOT.
Tomcat's WEB-INF directory is typically C:\Program
Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF.


The last step is to let the Web server know
where the TLD files are stored. You do this by modifying the
web.xml file, which should be located in your WEB-INF
directory. Listing
B.1 shows a web.xml file that uses all four JSTL tag
libraries.


Listing B.1
A web.xml That Uses All Four JSTL Taglibs
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/
core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/sql</taglib-uri>
<taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/fmt</taglib-uri>
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/xml</taglib-uri>
<taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>

</web-app>

As you can see in Listing
B.1, each of the four tag libraries has a separate taglib
entry. This is the same format that is used for every tag
library you'll use. To use any tag library, you simply include
the correct taglib-uri and taglib-location
properties. Now that you have successfully installed the JSTL
required files to their proper locations, you can construct a
JSP page that contains JSTL tags.











     Print  
     E-Mail
     
     Add
    Note    Add
    Bookmark
       




    Top

    [0672324504/app02lev1sec5]






     
     

    No comments:

    Post a Comment