Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

scriptlet VS Tag in JSP  RSS feed

 
krishna bethanabhotla
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Would like to know if a scriptlet or tag in JSP would be faster interms of performance.
Any idea is appreciated

krishna
SCJP1.4
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference is trivial.
I'd be more concerned with clarity and maintainability.

If a tag means pulling out non-view stuff that a web designer could break, then it would be well worth the microseconds lost (if there are any).
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only real difference is in the time it needs to compile.
Scriptlets are added to the generated Java source verbatim, while tags need to be parsed to generate the method calls (and potentially object instantiations) they represent.
At runtime the difference is probably trivial.

The only real difference is that using scriptlets you're able to get more code into your JSP as tags will typically result in more and longer method calls.
But if your JSP is getting so large that switching from scriptlet code to tags brings you over the maximum size for methods the JVM will accept (64KB compiled code per method) you have more serious problems and should really split up the JSP into several distincs modules using <jsp:include> tags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!