1.Jsp输出元素: <%=i%>
2.Jsp声明元素: 《声明全局变量和方法》
<%! %>
eg: <%! String name="Sophia";
Date getdate=new Date();
%>
3.用include指令将相关文件插入到JSP网页:包括文本文件,HTML文件或者JSP文件
eg:<%@ include file="relativeURL"%> //file 是指所要加载的文件路径
4.声明程序段代码<%%>
eg:< % for(int i=0;i<10;i++)
i=i+2;
%>
4.JSP内置对象:
request对象:客户端想服务器发送的请求信息,在服务器端通过:request.getParameter("变量");
用<form id="form1" name="form1" method="post" action="request.jsp">
method: post/get
action:
如:在message.jsp里实现一个可供用户填写信息的表单,将相关的信息提交给request.jsp页面去处理
eg:message.jsp:
<% @page pageEncoding="GB2312"%>
<%@ page contentType="text/HTML;charset="gb2312"%>
<%
request.setCharacterEncoding("GB2312");
%>
<html>
<head>
<title>tianxiebiao</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="request.jsp">
<p>name:
<label>
<input type="text" name="name" id="name"/>
</label>
<p>
<label>
<input="submit" name="submit" id="submit" value="Submint"/>
</form>
</body>
</html>
reuqest.jsp
<% @page pageEncoding="GB2312"%><%@ page contentType="text/HTML;charset="gb2312"%>
<%
request.setCharacterEncoding("GB2312");
%>
<html>
<head></head>
<body>
<% String name=request.getParameter("name");
%>
</body>
</