Chapter 20: The Bean Tag Library

 < Day Day Up > 



At this point, we begin our discussions of the Jakarta Struts tag libraries. In this chapter, we examine the Jakarta Struts Bean tag library. The Bean tag library provides a group of tags that encapsulate the logic necessary to access and manipulate JavaBeans, HTTP cookies, and HTTP headers using scripting variables. There are currently 11 custom tags in the Bean tag library.

Installing the Bean Tags

To use the Bean tag library in a Web application, you must complete the following steps, replacing the value webappname with the name of the Web application that will be using this library:

  1. Copy the TLD packaged with this tag library, struts-bean.tld, to the <CATALINA_HOME>/webapps/webappname/WEB-INF/ directory.

  2. Make sure that the struts.jar file is in the <CATALINA_HOME>/webapps/webappname/WEB-INF/lib directory.

  3. Add the following <taglib> subelement to the web.xml file of the Web application:

     <taglib>   <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>   <taglib-location>/WEB-INF/struts-bean.tld</taglib- location> </taglib> 

You must add the following taglib directive to each JSP that will leverage the Bean tag library:

 <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 

This directive identifies the URI defined in the previously listed <taglib> element and states that all Bean tags should be prefixed with the string bean.



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

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