April 12, 2011

Setting up JSTL in JBoss 4.2.2GA

The JBoss4.2.2GA Application Server contains the dependent jar/s for JSTL support in JSPs. The dependent jar - jstl.jar - is present in the following folder of JBoss4.2.2GA:

%JBOSS_HOME%/server/default/deploy/jboss-web.deployer/jstl.jar

1) Open the jstl.jar with an archiving tool such as WinRar. Explore into the META-INF folder within the jstl.jar

2) The META-INF contains the tld files for all the JSTL tag libraries such as the core, fmt, xml, sql and functions tag libraries.

3) To use JSTL tags for a particular library, for example, the core library, open the c.tld file and look for the <uri> element in the tld file.

For the c.tld in JBoss4.2.2GA, the <uri> element is the following:
<uri>http://java.sun.com/jsp/jstl/core</uri>

The contents of the <uri> element is needed for the taglib directive in the JSP that will contain the core library JSTL tags.

4) In the JSP which contains the JSTL tags from the core library, add the following taglib directive. The contents of the <uri> element are the value of the uri attribute in the taglib directive.
Note: Create a new JSP in your web application and add this taglib directive at the top of that JSP.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


5) Test if JSTL has successfully been setup by put the following out tag in the JSP as follows:

<body>
   <c:out value="Testing JSTL" /> 
</body>

No comments:

Post a Comment