Web App Development Part III: Developing JSP Custom Tags

Discussions

News: Web App Development Part III: Developing JSP Custom Tags

  1. The third installment in Qusay Mahmoud's "Web Application Development with JSP and XML" article series. The third part covers building JSP Custom tags. It shows how to build simple and complex tags along with writing Tag Library Descriptors.

    Part 3: Developing JSP Custom Tags

    Part : JSP with XML in mind

    Part 1: Fast Track JSP
  2. Thanks to Qusay Mahmoud for the overview. While I understand this article is tutorial in scope, having used custom tags extensively myself I wonder if anyone knows if there are any extensions on the horizon to get around a couple limitations to the spec i worked with (taglib 1.0).

    Taglib 1.0 limits the number of TLD's per jar to 1 and furthermore must comply with a naming convention. You CAN store more than one there and you can name it whatever you want but only the one correctly named TLD can be used directly from the jar - i.e., without manually extracting and installing the TLD yourself. It would be handy to have multiple TLD's for different 'views' on an API (e.g., "light" v. "power-user", or "verbosely named tags" v. "cryptic tag names").

    = Mark
  3. Documenting JSP Custom Tags[ Go to top ]

    Another thing I'd like to see is a JavaDoc-like facility for documenting TLD's. This is missing in taglib 1.0, i'm wondering if it is or will be in a later version.

    Custom tags do a nice job of separating the presentation layer from the business logic but in order for the user to understand what a tag library can do (at least in taglib 1.0) either

    (a) the user must eyeball TLD.

    (b) the developer must provide user with a viewer that will extract comments, command names & arguments and pretty print them.

    (c) the user must refer back to the javadocs for the underlying class files (including TEI's in the case where page variables are created).

    (d) developer must create a separate document and be disciplined about keeping it up to date with the TLD.

    = Mark

  4. Documenting JSP Custom Tags[ Go to top ]

    <p>I am totally new to tag library. I read thru your article and found that the tag library is a cool concept and can very well be adopted in projects. I have a trivial question here.
    </p>
    <p>
    I understand that defining tags makes it posible for generic functionality to be shared across modules in an application or across applications. Say for example i would like to show the list of Customers by querying a database and populating it in a drop down list box. i can define a Customer tag and write a class to do this. in my jsps i can now use the customer tag to get a list of customers.
    </p>
    <p>
    I can also write a jsp file that will query the database and populate the drop down box. In this case i only need to use the include directive to insert the jsp into the calling jsp.</p>
    <p>
    SELECT name=cust multiple size=4>
    %@ include file = "CustNames.jsp" %>
    SELECT>
    </p>
    <p>
    If you look at it.. this approach is also modular. It is much simpler also. for the reason there is no hassles of TLD, no need to write a new class, development is easier u can make a change and see the change getting reflected immediately.. if u write a class and jar it u may have to bring down the server.
    </p>
    <p>
    This might be a trivial doubt.. so please correct me if my idea is wrong.</p>