Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scriptlet, EL, JSTL, Custom tags, what is the loading/rendering sequence?

 
Lorenz Baylon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi fellow Ranchers,
Does anybody know about the loading sequence when a jsp file contains scriptlets, EL, JSTL/custom tags? What I mean is which is being read first before which? Or does their position in the jsp file is the only thing that matters? Thanks in advance.

Lhorenz
[ July 10, 2008: Message edited by: lhorenz baylon ]
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scriplets are embedded in the servlet generated from the JSP page - so obviously only their position matters. EL is similar, but uses the EL API behind to scenes to achieve it's goal - again, this is invoked in a procedural manner as the part of the page containing the EL is executed.

Actions (including JSTL and custom tags) are also executed when they are encountered in the page, though there are multiple methods to invoke in this case since tags have their own lifecycle which can be quite complicated. Nevertheless, these are all invoked in the correct sequence by the container at the point the tag is found in the page (otherwise your output wouldn't be where you'd expect it!). There is a slight complication here: sometimes to save on object counts (memory overheads), a JSP page will reuse the same tag handler instance for multiple invocations of the tag - but you don't need to worry about this as the container will handle it all seamlessly (it is a container-dependent feature too).
 
Lorenz Baylon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Charles! I was thinking earlier that they are being translated/evaluated at different phase/pass though the jsp file translation. Very well said. Thank you.

Lhorenz
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic