Women in Technology

Hear us Roar



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="..."


I didn't see this used anywhere in the tag file. Is it necessary?


Also I believe this:


img src="${imgDir}$"


should really be this


img src="${imgDir}$/${image}"


-Jerome

Main Topics Oldest First

Showing messages 1 through 1 of 1.

  • Writing Tag Files
    2004-02-15 07:14:47  bperry [View]

    Thanks for pointing this out Jerome. The "img" tag is an editorial typo that hasn't been fixed yet. It should look like (minus the opening and closing "< >" so it will display in this message):

    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!