I've read many things that say to u开发者_运维知识库se JSTL or EL in JSPs.... I'm just curious; does using scriptlets in JSP affect the performance of the page?
The general advice to use JSTL and EL instead of scriptlets has absolutely nothing to do with performance; if anything, scriptlets are likely to yield better performance.
But they also lead to "tag soup" that is hard to maintain. You're supposed to use JSTL/EL because JSPs are supposed to be a presentation layer and not contain significant logic.
First, using scriptlets (embedding raw Java code in JSP using the old fashioned <% %>
things) is not the same as using taglibs (e.g. JSTL) and EL (the ${}
things).
The performance penalty of taglibs and EL is really negligible and only noticeable during compilation and does by far not outweigh the advantages of using taglibs and EL instead of scriptlets.
All JSP taglibs and scriptlets get compiled to a Java class before execution, so there's virtually no performance difference for using one or the other.
精彩评论