What is the advantage of using JSP tag then writing Java code in <% %> and which has got better performance
Post by:Sam Dalton
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
This thread has been viewed 699 times.
All times above are in ranch (not your local) time.
The current ranch time is Dec 18, 2018 05:41:26.