• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

TagLibs in JSP

 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I was wondering, when to use the Taglib feature of JSP.We could use the JavaBean feature to do most of the presentation logic.
Is there a performance hit, if we decide to put the presentation logic in the JavaBean instead of using the Taglibs?
The only advantage that I can see using taglibs is that, the JSP becomes concise.However, it becomes more cryptic to a HTML designer who may not be a decent Java programmer.In that case, it goes against the principle on why JSP is prefered over servlets - allowing Web designers to work in parallel with the Java Developers so that static content is separated from dynamic content.
Please advise.
Regards,
Sandeep Desai
[This message has been edited by Desai Sandeep (edited April 24, 2001).]
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can do everything you need with JavaBeans rather than custom tags, I would probably lean that way. However, I have run into things that can only be done in Java scriptlets or in custom tags. This includes things like passing collections (rather than scalar values) and handling iterations. If all you need Java in your JSPs for is storing and retrieving scalar values, JavaBeans should do the work nicely. However, if you need to employ significant Java processing with the JSPs, custom tags seem more appropriate to me.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dustin,
Thanks for the response.
As regards handling iterations, I have done that through the JavaBean code.Is there any reason, why I need to switch that code to the custom tag?
Also, could you please clarify on what you meant by passing Collection?Are you trying to pass HashSets, HashMaps, Vectors, etc.Could you please post a sample code here.
Thanks in advance
Regards,

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
 
Dustin Marx
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.
When I was talking about collections, I was talking in general terms about any of the collections you listed or others. Although JavaBeans can handle these, we are trying to avoid the need to have Java Scriptlets in the JSP to iterate over the returned collections. Thus, for us, the only way to reduce the Java in the JSP and handle non-scalar data is to use custom tags that iterate for us. I guess there are other ways of handling these collections with JavaBeans and avoiding Java code in the JSP (such as storing a "list" of elements in a single String with a delimiter marking each element), but we decided it was more straight-forward to use custom tags.
I would say it comes down to trade-offs between the two approaches and what you are most comfortable with. I know many people aren't bothered in the least by mixing HTML and Java in their JSPs while others will go to any length required to completely separate the two.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dustin,
Thanks for your reply.
If I consider iterating through the collection and creating the HTML form in the JavaBean code, instead of doing it with custom tags,what I understand is, there would not be any performance hits.
It just boils down to the fact, whether you are comfortable using JavaBeans or the custom tags...Right?
The only other consideration (or should I say cons!!) with JavaBeans is that you cannot avoid scriplets completely, like custom tags..Right?
Thanks in advance,
------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
 
Dustin Marx
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe you are correct that there are no significant performance differences. As far as I can tell, I agree that the main deciding factor for determining whether to use JavaBeans or custom tags is your tolerance for Java scriptlets in the JSP. Maybe someone else knows of some other differentiating factors?
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my case, I was told to do a customerize tag lib so that in the future, the client side developer can just use the tag, which will be the only code that is sort of java in the page, and it would be easy for them to learn because of the format.
tag lib has certain limitation comparing to bean
just my $0.02
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic