- <%!declaration; [declaration;]+...%>
- <%@page attribute1="value1" attribute2="value2" ...%>
- <jsp:directive.page attribute1="value1"...>
- <%@page contentType="text/html; charset=utf-8" language="java" import="java.net.*"%>
- <%@include file="relativeURLspec"%>
- <jsp:directive.include file="relativeURLspec">
- <%@include file="Hello.html">
- <%@taglib uri="tagLibraryURI" prefic="tagPrefix"%>
- <jsp:directive.taglib uri="tagLibraryURI" prefic="tagPrefix">
- <jsp:include>
- <jsp:forward>
- <jsp:param>
- <jsp:useBean>
- <jsp:setProperty>
- <jsp:getProperty>
- String getProtocol() 获取通信所使用的协议和版本号(如:HTTP /1.1)
- String getScheme() 获取请求中的协议名称(如:HTTP)
- String getPathInfo() 获取请求中处于JSP路径和查询字符串之间的额外信息
- String getContextPath()
- String getRequestURI()
- String getServletPath()
- String getRealPath(String path)
- String getServerName() 获取响应请求的服务器名称。
- int getServerPort() 获取响应请求的服务器端主机端口号。
- String getLocalName() 获取响应请求的服务器端主机名。
- String getLocalAddr() 获取响应请求的服务器端地址。
- int getLocalPort() 获取响应请求的服务器端端口。
- String getRemoteAddr() 获取发出请求的客户端IP地址。
- String getRemoteHost() 获取发出请求的客户端主机名。
- int getRemotePort() 获取发出请求的客户端主机端口。
- String getParameter(String name) 获取客户端发送给服务器端的参数值。
- Enumeration getParameterNames() 返回请求中所有参数的集合。
- String[] getParameterValues(String name) 获得请求中指定参数的所有值。
- http://localhost:8080/liuxl/jsp/querystring.jsp?str=JSP
- String s=request.getParameter("str"); 获取变量str的值,执行后s的值为“JSP”。
- if(request.getParameter("val")!=null) //判断字符串是否为空
- {
- num=Integer.parseInt(request.getParameter("val")); //将字符串转化为整数
- }
- else
- {
- num=0;
- }
- if(request.getParameter("val")!=null) //判断字符串是否为空
- {
- num=Integer.parseInt(request.getParameter("val")); //将字符串转化为整数
- }
- else
- {
- num=0;
- }
- <form name="" action="" method="">
- ...
- </form>
- 文本框:<input name="" type="text" value="" size="" maxlength="">
- 密码框:<input name="" type="password" value="" size="" maxlength="">
- 提交按钮:<input name="" type="submit" value="">
- 重置按钮:<input name="" type="reset" value="">
- 单选按钮:<input name="" type="radio" value="" checked>
- e.g:<input name="radiobutton" type="radio" value="1" checked>选项1
- <input name="radiobutton" type="radio" value="2">选项2
- 复选框:<input name="" type="checkbox" value="" checked>
- e.g:<input name="checkbox" type="checkbox" value="swim">swim
- <input name="checkbox" type="checkbox" value="run">run
3、<select>标签 声明了一个可选项的列表,用户可以选择一个或多个选项
- <select name="" size="" multiple>
- <option value="" selected>option</option>
- ...
- <option value="">option</option>
- </select>