aspose file tools*
The moose likes JSP and the fly likes Tag Library!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Tag Library!!!" Watch "Tag Library!!!" New topic
Author

Tag Library!!!

Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
hi folks,
I read some articles that Tag Library is used to group a java code written in JSP using scriptlet and move them out of JSP into a library that a Page authour can then use as html tag fashion. why not use Java Bean to group such java code in JSP instead of Tab Library? What advantages and particulare need the Talg Libraray has over Java Bean? could you please clarify me?
thanks.
zhu a ming
Greenhorn

Joined: Oct 05, 2003
Posts: 9
Tag Library is not easy!!
There is many Tag Library in the starts
The Tag Library is to in fact is a page for the sake of the simplification jsp


=======================<br />s=(LinkNode *)malloc(sizeof(ListNode));<br /> s->date=ch;<br /> s->next=head;<br /> head=s;<br /> ch=getchar();
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61412
    
  67

You could probably get any number of reasons to use custom tags over beans -- but in all honesty I have no idea what the previous poster is trying to say.
Search through this forum for previous topics on the same subject for other views.
If I get a chance later I'll enter a lengthier response, but in short for me it's all a matter of abstraction. I find that it's much easier to abstract page elements using custom tags of my own design, rather than trying to shoehorn it into beans.
While beans are great for value objects, if the abstracted elements need to generate HTML and/or Javascript output, it's bending the bean architecture a bit to produce it and render it to the JSP output buffer. The custom tag architecture is better integrated into the JSP environment, and is ideally suited to spitting out HTML and Javascript. as well as performing a whole host of other page-related functions.
Those aren't the only benefits or reasons, but they're the ones that sold me on the whole concept. I'm sure other tag enthusiasts will have their own favorite reasons.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
varun bihani
Ranch Hand

Joined: Aug 11, 2003
Posts: 96
Sir,
I want to know something more about Tags.. To me also it seems Tags helps in reducing the Javascripts and HTML codes in my jsp...
But is it also helpful in business logics like beans???


<a href="http://www.galaxyweblinks.com" target="_blank" rel="nofollow">www.galaxyweblinks.com</a><br /><a href="http://www.freechatcode.com" target="_blank" rel="nofollow">www.freechatcode.com</a><br /><a href="http://www.onlinefamilytreemaker.com" target="_blank" rel="nofollow">www.onlinefamilytreemaker.com</a>
Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
Any Bean is also a Custom Tag, but not vice versa.
<jsp:useBean> or <comma:geneus-writeTheDate-gottenFromSybaseDatabase>
CT +:
Threading is dealt by the container.
You can access all the context values directly, i.e. request, response, session etc.
Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
although there are responses to my queries on Custom Tag, I am still not comfortable what advantages the Custom Tag has over JavaBean. I went through a couple of books and I undertand that both are used to seperate Java Code from JSP and encapsulate them and used in a HTML tag fashion. I found one of the interesting reason why Custome Tag is better choice than Java Bean is that "notion of ieteration, nesting or cooperating action is not better expressed with Java Bean" but with Custom Tag.
Also i found this JavaBeans can not interact with the JSP page: they do not have access to the request and response objects and you can't use them to perform the decision-making processes What does it mean? why can't we do iteration in JavaBeans? Why JavaBeans does not have access to request and response? could anyone please explain me in layman's term? it would be really great help. thanks.
[ October 19, 2003: Message edited by: Namaste Sathi ]
T Rai
Greenhorn

Joined: Apr 16, 2002
Posts: 20
Originally posted by Namaste Sathi:
"notion of ieteration, nesting or cooperating action is not better expressed with Java Bean" but with Custom Tag.
Also i found this JavaBeans can not interact with the JSP page: they do not have access to the request and response objects and you can't use them to perform the decision-making processes What does it mean? why can't we do iteration in JavaBeans? Why JavaBeans does not have access to request and response? could anyone please explain me in layman's term? it would be really great help. thanks.
[ October 19, 2003: Message edited by: Namaste Sathi ]

i think what that means is that you can't use JSP implicit objects like pageContext, request, response etc in JavaBean. And also, when you write JavaBean based on the specification you can't write any other methods other than getter and setter for properties. You can write other methods other getter and setter, it does not become a JavaBean but a Java Class. So to include such methods, you are better of putting such things in Custom Tag.that's my understaing. Others might want to add clarification if I am wrong here.
Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
I still have some problem with Custom Tag. while creating custom tag, we override doStartTag or doEndTag. What determines which one these method we should override?
thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tag Library!!!