• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

What are tag libs?

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may look like a sally question, but I really don't have an idea about how do they work, anf how do I use them.
Can anyone give me an example of a reusable tag, and a tag lib?
Are those related to java packages?, or java beans?
Thanks.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chk out these tutorials. for details.
Basically Tag Libs are a way to develop your own tags like the
ones you use in HTML ex: H1, H2 etc for headings etc.
Not direclty related to packages or beans, but they can be developed using bean concepts.
regds.
- satya
 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP tag libraries are a collection of custom built tags which produce an XML-based script (custom actions presented as tags). The logic component is separated in a JavaBean.
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And may this tags have behavior or are they only for format purposes.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, they could have behavior, like in a table,
repeating a certain steps in a for loop etc.
Is this what you are asking when you say "behavior"?
Not sure I understand you correctly.
regds.
- satya
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP Tags have whatever behavior you program into them. There are tags that allow logging to occur from your JSP page so you can track thing. The Jakarta full Tag Lib has session tags, request and response tags, log tags, db tags etc.
------------------
Hope This Helps
Carl Trusiak, SCJP2
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Madhav, Joe, Carl.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Taglibs are a collection of Java Classes that follow the Java Beans model ,and implement a particular function ( like iterating thru a collection or a recordset).These functions are accesible in JSP using custom tags.
Custom tags are similar to ordinary tags in HTML like <HTML>/<HTML> , <BODY>/<BODY>.
You can specify your own name for these with a set of attributes foe each tag. Each tag would have a TagHandler class ( the Java Class I mentioned above), that would implement a Tag Interface or
derivative of it (javax.servlet.jap.tagext.*). The TagHandler would need to have a setter method for each of the attributes.
The Tag Handler would implement the exact function of the Tag and a TagLibraryDescriptor (which is a XML file) would create a mapping between the tag handler class and the tag name.
It would also contain additional details on the attributes, their types,variable defined by the tag if any ,and auxiallary calsses to validate the tags.
eg:
<foo:customtag attri1="val1" attr2="val2">
//Body of the tag
</foo:customtag>
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yep and the best part about defining your own tags is
1. you have no trouble implementing OLAF (one look and feel in your application or across multiple applications)
2. Changes/modifications have to be made in one place and not in individual jsp's
3. You are following sun's new pattern Model-View-Control to the t (or is it z...)
and i really want this book :-)
-manav
 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand why do we need to specify the prefix attribute in the taglib directive though. I think specifying the uri attribute should be enough to let the JSP container to look for the tag because the tag tld already linked the uri "name" to the "tag".
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The prefix is especially useful when you are using more than one library of tags in a particular JSP to prevent name conflicts.
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic