First, the JSP comments
<!--visible in the client-
<%--is not visible in the client
JSP script Comment://single-line comment/**/Multiline comment
Second, the JSP statement
<%! %>
Third, JSP printing 99 multiplication table
Expression mode and script mode
<%@ page language= "java" import= "java.util.*" contenttype= "text/html"; Charset=utf-8 "%>
<%
String path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
<base href= " <%=basePath%>
<title>my JSP ' jiujiu.jsp ' starting page</title>
<meta http-equiv= "Pragma" content= "No-cache",
<meta http-equiv= "Cache-control" content= "No-cache";
< Meta http-equiv= "expires" content= "0" >
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3"
<meta http-equiv= "description" content= "This is my page";
<!--
<link rel= "stylesheet" type= "Text/css" href= "Styles.css";
-->
<body>
<%!
Returns a 99 multiplication table, called through an expression, displayed on the page
String printmultitable () {
String s = "";
for (int i=1;i<=9;i++) {
for (int j=1;j<=i;j++) {
s+=i+ "*" +j+ "=" +i*j+ " ";
}
s+= "<br>";
}
return s;
}
To print a 99 multiplication table using a scripted method
void PrintMultiTable2 (JspWriter out) throws exception{
for (int i=1;i<=9;i++) {
for (int j=1;j<=i;j++) {
OUT.PRINTLN (i+ "*" +j+ "=" + (i*j) + " ");
}
Out.println ("<br>");
}
}
%>
<%=printmultitable ()%>
<br>
<% PrintMultiTable2 (out); %>
</body>
JSP Print 99 multiplication table