What will execute first body elements or head elements...
- Head
- Body
- scriplet
If I get what you're asking, each element in the JSP file is processed in the same order as it appears from top to bottom of your code.
Obviously, the scriptlets embedded in your JSP are executed to create the HTML. The scriptlets, and other server-side-executable stuff in the JSP is executed top to bottom.
(The JSP is not aware of the HTML elements it is generating. It processes the JSP / JSTL syntax embedded in the JSP file, and treats the rest as text to be copied into the document sent to the browser. That's why you can, in theory, use JSPs to generate any text-based document.)
The generated HTML is then sent to the browser ... which is where any client-side javascript embedded in the HTML will be executed.
JSPs are servlets that add syntactic sugar to facilitate developers. All JSP compile to servlet first and at runtime class files of that compiled JSP.
Following diagram explains the JSP compilation/execution in detail:
HTML/JS are executed on browser(client side) once server side script finalize the response as HTML.