Win a copy of Microservices in Action this week in the Web Services forum!
  • 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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

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..
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!