Section 16.6. WEB-INF

   

16.6 WEB-INF

The WEB-INF folder contains classes, including beans and tags, as well as the web.xml file.

16.6.1 web.xml

 <?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>   <description>an online store</description>   <taglib>     <taglib-uri>http://store.mysite.com/tags/cart</taglib-uri>     <taglib-location>/WEB-INF/cart.tld</taglib-location>   </taglib> <!--JSP Standard Tag Library 1.0 Core tags-->  <taglib>   <taglib-uri>http://java.sun.com/jstl/ea/core</taglib-uri>   <taglib-location>/WEB-INF/jstl10/tld/c.tld</taglib-location>  </taglib> </web-app> 

In the web.xml file, we need to declare that we want to use the JSTL core tags, and we point to their TLD. We do the same for our custom tags. The only difference is that c.tld is defined by the Jakarta project, and we just need to put it in the right place, but we have to write our own cart.tld . So that is shown next .

16.6.2 cart.tld

[View full width]
 
[View full width]
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"> <taglib> <tlib-version>1.0</tlib-version> <jsp-version>1.2</jsp-version> <short-name>ecommerce shopping cart</short-name> <description>a shopping cart</description> <tag> <name>message</name> <tag-class>com.cybertrails.store.tags.MessageTest </tag-class> <body-content>empty</body-content> <description>test: show a message</description> <attribute> <name>message</name> <required>true</required> <rtexprvalue>false</rtexprvalue> <type>java.lang.String</type> </attribute> </tag> <tag> <name>view</name> <tag-class>com.cybertrails.store.tags.ViewCartTag </tag-class> <body-content>empty</body-content> <description>view contents of the shopping cart </description> </tag> <tag> <name>product</name> <tag-class>com.cybertrails.store.tags.ProductCartTag</tag-class> <body-content>empty</body-content> <description>add items to a cart</description> <attribute> <name>action</name> <required>true</required> <rtexprvalue>false</rtexprvalue> <type>java.lang.String</type> </attribute> <attribute> <name>productid</name> <required>false</required> <rtexprvalue>false</rtexprvalue> <type>java.lang.String</type> </attribute> </tag> <tag> <name>checkout</name> <tag-class>com.cybertrails.store.tags.CheckoutTag </tag-class> <body-content>empty</body-content> <description>walk through checking out process </description> <attribute> <name>action</name> <required>true</required> <rtexprvalue>true</rtexprvalue> <type>java.lang.String</type> </attribute> </tag> <tag> <name>calculate</name> <tag-class> com.cybertrails.store.tags.CalculateCartTag </tag-class> <body-content>empty</body-content> <description>calculates shipping, tax, and total for final checkout page</ graphics/ccc.gif description> <attribute> <name>item</name> <required>true</required> <rtexprvalue>true</rtexprvalue> <type>java.lang.String</type> </attribute> </tag> </taglib>

The TLD describes where the container can find the classes for custom tags and how they must be called.


   
Top


Java for ColdFusion Developers
Java for ColdFusion Developers
ISBN: 0130461806
EAN: 2147483647
Year: 2005
Pages: 206
Authors: Eben Hewitt

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