• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP Tag  RSS feed

 
pradeep anandan
Greenhorn
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

Regards,
Pradeep
 
Sam Dalton
Author
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..
Cheers
Sam
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!