Monday, May 30, 2005

Tips: Using JSTL with Struts

A hands-on approach:
a. JSTL 1.1.2 requires a JSP container that supports the Java Servlet 2.4 and JavaServer Pages 2.0 specifications. Jakarta Tomcat 5 supports the new specifications.
b. Download and install JSP Standard Tag Library (JSTL) version 1.1.2
c. From the jakarta-taglibs-standard-1.1.2\lib folder:
Copy the jstl.jar and standard.jar into your applications WEB-INF\lib folder and copy the c.tld, fmt.tld, sql.tld and x.tld files into your applications WEB-INF\lib folder.
d. Use the appropriate taglib directives on your JSP pages where you want to use JSTL, for example:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
Many of the JSTL tags can replace the existing difficult to use, Struts tags.
e. A lot of confusion exists about Struts-EL tags. Please note that if a Struts tag can be replaced by a JSTL tag, then that tag is not implemented in the Struts-EL tag libraries.
f. JSP 2.0 supports the use of EL expressions directly on a JSP page. Since we are using Servlet 2.4 specification, EL is enabled by default. Of course your applications web.xml file must have this at the beginning of the file:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

Technorati Tags: , ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home