The position of js in the jsp page is as follows:

The corresponding code is as follows:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="./WEB-INF/includes/taglibs.jsp" %>
<script type="text/javascript">
console.log("it is before !DOCTYPE html");
</script>
<!DOCTYPE html>
<script type="text/javascript">
// test2();
console.log("it is before html");
</script>
<html>
<script type="text/javascript">
console.log("it is in html before head");
</script>
<head>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="format-detection" content="telephone=no">
<script src="<%=uiPath%>ui/jquery/jquery.min.js" type="text/javascript"></script>
<link href="<%=uiPath%>ui/skins/default/css/test.css" rel="stylesheet" type="text/css" />
<link href="<%=uiPath%>ui/skins/default/css/commons.css" rel="stylesheet" type="text/css" />
<script src="<%=uiPath%>ui/js/commons.js" type="text/javascript"></script>
<script src="<%=uiPath%>ui/js/common_edit.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
console.log("it is in head");
});
</script>
</head>
<script type="text/javascript">
console.log("it is after head before body");
</script>
<body>
<h2>Hello World!</h2>
<script type="text/javascript">
console.log("it is in body");
</script>
<div>
<span class="testls">test link script</span>
</div>
</body>
<script type="text/javascript">
console.log("it is after body before </html>");
</script>
</html>
<script type="text/javascript">
console.log("it is after </html>");
</script>
Browser execution of html code is a linear process from top to bottom,<script>Follow this principle as part of the html code!
The JS in the HTML head section will be executed when it is called.
Other parts of the JS will be executed when the page loads.
The effect of execution sequence is as follows:

That is, the js in the head tag is executed last, and the other places are executed when the page loads in the order of up and down.
Three possible locations in the actual project:
① Between heads;
② Inside the body;
③ Behind the body.
Among them ②③ is for dynamically generating the page, ① is for the function call after the page is loaded.
The order of execution of js in the page: add a piece of js code in the head tag of the page, add a piece of code before the end of the page is </body>, and then reference a function in the body...
JSP = JAVA + HTML, i.e., embedded Java code in the HTML code fragments. When first run .jsp file compiled into servlet (ie java file), and then compiled into .class files. JSP, JAVA code execution on ...
jQuery $ (document) .ready () execution order: When after the page DOM element is fully loaded execution .ready (). $ (Document) .ready () isDOM structure drawing is completed after execution, Without...
When working on a project today, the expected effect: click the save button, the loading picture will circle, and the picture (a dozen or so) will be submitted to the server in a single cycle; Actual ...
First request: When a JSP page on the server is requested to execute for the first time, the JSP engine on the server first translates the JSP page file into a .java file, which is a servlet, and comp...
I recently made a management system for the school and encountered similar problems. The idea is to write some news and dynamics in Word, and then load them into the designated location of Html. becau...
FROM Determine the data source WHERE Filter according to requirements and discard data rows that do not meet the requirements GROUP BY Groups and counts the previous data, and reduces the result set t...
JSP page execution process What JSP: The essence of jsp is servelt, which is equivalent to a servlet packaging. JSP: java + server + pager jsp is the sum technique: jsp = html + css + javascript + jav...
Layer.js address...