jsp (2) annotation of Java Web

HTML Comments

HTML comments can be used in jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <!-- this is body -->
    <!-- todsy is <%=new java.util.Date().toString() %>-->
</body>
</html>

The results are as follows:

Although you can't see things on the surface when using HTML annotation, you can still see when you open the browser to view the source code, which belongs to you

jsp notes

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

    <!-- this is body -->
    <!-- todsy is <%=new java.util.Date().toString() %>-->

    <%-- this is jsp comments --%>
</body>
</html>

The results are as follows:

jsp comments, when you look at the page source code is not visible.

Comments in jsp segments

The comments in the jsp program segment are the same as the java comments, and the java single line and multi line comments can be used normally.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

    jsp Segment comment
    <%
        //Single-Line Comments
        /*
        *multiline comment
        */
    %>
</body>
</html>

Tags: JSP Java

Posted on Fri, 27 Mar 2020 10:12:48 -0700 by adamdyer