| Article: |
Six Cool New JSP and Servlet Features | |
| Subject: | Writing Tag Files | |
| Date: | 2004-02-13 12:54:32 | |
| From: | jjacobs0 | |
|
The article section 5 "Writing Tag Files" shows an example tag file. What is the purpose of the following?
taglib prefix="c" uri="..."
img src="${imgDir}$"
img src="${imgDir}$/${image}"
|
||
Showing messages 1 through 1 of 1.





img src="${imgDir}${image}" width="${width}" height="${height}" align="left"
The imgDir attribute includes the forward slash ("/") to separate the directory location from the image name. This article doesn't show it, but "imgDir" was previous bound as a session attribute, as in: "<% session.setAttribute("imgDir",(request.getContextPath() + "/images/"))
%>"
The "taglib" directive is in the book's example "tag file," from which this article section is derived (recipe 22.11). The book example used the "c:out" element from the JavaServer Pages Standard Tag Library (JSTL) to output the EL statements in the tag file. However, this article uses EL code embedded in the tag file's template text (as you can do with a JSP 2.0 container; see #4 above). Therefore, the taglib directive isn't necessary here (because we're not using the "c:out" element that the taglib directive makes available); it was an oversight in the article. Thanks again!