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.
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).
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )
Joined: Jan 04, 2006
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.