1.JSP page Element Introduction and page directive 2.JSP Comment, 3 different annotations<!--I'm an HTML comment, visible on the client--<%--I am a JSP comment that is not visible on the client--%>
<% //I am a script line comment / * I'm a script multiline comment script Comment not visible on client * / %>
3.JSP script for writing scripts, syntax: <%%><%Out.print ("Welcome you to learn Java EE course"); %>
4.JSP Declaration,used to declare Java variables or partieslaw, Syntax: <%! variable or method%><%! String s="China"; int Add (int x,int y) { return x+y; } %>
5.JSP expression, an expression executed in a JSP page (invoking a declared variable or function), syntax: <%= expression%>//Note expression does not end with good points Hello,<%=s%>5+10=<%=Add (5,10) %>
6.JSP page life cycle 7. Related Exercises
12345678910111213141516171819202122232425262728293031323334353637383940 |
<%@page import="org.apache.jasper.tagplugins.jstl.core.Out"%>
<%@ 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=ISO-8859-1"
>
<
title
>九九乘法表</
title
>
</
head
>
<
body
>
<
h1
>九九乘法表</
h1
>
<
hr
>
<%!
//通过表达式来实现
String printMultiTable1(){
String s="";
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){
s+=j+"*"+i+"="+(i*j)+" ";
}
s+="<
br
>";
}
return s;
}
//使用脚本来实现
void printMultiTable2(JspWriter out)throws Exception{
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){
out.println(j+"*"+i+"="+(i*j)+" ");
}
out.println("<
br
>");
}
}
%>
<%=printMultiTable1() %>
<
hr
>
<% printMultiTable2(out); %>
</
body
>
</
html
>
|
From for notes (Wiz)
Java's JSP basic syntax