Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JSP Tag  RSS feed

Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the advantage of using JSP tag then writing Java code in <% %>
and which has got better performance

Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Primary benefits are related to maintainability and usability. If you code a piece of functionality into a tag then you can very easily reuse this across multiple pages and even multiple web applications. This is much harder with scriptlets.
Scriptlets create messy pages. You dont have any separation of concerns, with the display and logic mixed up together, this results in a maintainance headache. This is further compounded when pages are designed by non java programmers (Graphic Designers etc). It is easy to teach such people how to use a given tag, but much harder (and pointless) to teach them Java.
As for performance, there is little or nothing in it. At the end of the day a tag equates to simple method calls when a JSP is translated to a servlet, in exactly the same as a scriptlet would be translated. A potential performance gain that can be had by using tags relates to the fact that tag instances can be pooled by the web container. This means expensive object creation could potentially be done once only....
A good book that discusses these points in detail is Professional JSP Tag Libraries by Simon Brown.
Hope this helps..
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!