一、JSP Java Server Pages
1、JSP表达式
<%= %>  就相当于输出
2、JSP片段
<% %>    相当于service方法中的代码
3、JSP申明  
<%!  %>  相对于类的成员属性或方法
4、注释
<%-- 注释的内容不可见 --%>
<%
  //注释内容可见
%>
5、JSP指令   不直接输出内容,只是告诉JSP引擎如何处理JSP页面中的其余部分。
   page     当前jsp页面的一些设置
	---language  语言设置
	---import    导包
	---pageEncoding 编码设置
	---contentType  编码设置(一般设置一个就可以了)
	
	---errorPage 错误页面(当页面出现异常或错误时,跳转至指定页面,需要在指定页面的page指令中设置isErrorPage="true")
	---isErrorPage="true" 设置当前页面为错误页面。
	如果出现错误 返回500 服务器错误
	如果未写isErrorPage="true" 会返回200 表示没有错误
	错误页面的错误提示
    <%=exception.getMessage() %>
    <%=exception.getStackTrace()%>
    <%=exception.getLocalizedMessage() %>
   Include 包含
	----静态包含 <%@include file="路径" %>
		包含所有的代码和内容。
		
	----动态包含
<jsp:include page="路径"></jsp:include>
		包含的是内容,而不是代码
	
   taglib
	----后续再讲
二、域对象(四大作用域对象)
1、全局域---整个应用
   ServletContext---application(隐式对象)
2、请求域---一次请求
   HttpServletRequest---request(隐式对象)   
3、页面域---当前页面
   PageContext---pageContext(隐式对象)
   当前页面,离开当前页面就访问不了。
4、会话域
   HttpSession---session(隐式对象)
   一次会话,浏览器不关,session就不会销毁。
三、九大隐式对象
application:全局
request:请求
pageContext:当前页面
session:会话
response:响应
config:配置
out:输出
page: this
exception: 异常
四、获取域中属性的多个值
通过名称获取一组值。
String val[] = request.getParameterValues("ck");
再遍历出来即可。
for(String s:val){
	//System.out.println(s);
}
四.EL表达式的使用
单个参数取值 
param.属性
多个同名参数如何取值
paramValues.属性[下标]
1.基本数据类型 ${base}
2.数组类型 ${arr[0]} -- ${arr[1]} -- ${arr[2]}
3.ArrayList集合类型 
${list[0]} -- ${list[1]} -- ${list[2]}\
${list.get(0)} -- ${list.get(1)} -- ${list.get(2)}
4.HashMap集合类型 
${map.name} -- ${map.age } -- ${map.sex }
${map['name'] } -- ${map['age'] } -- ${map['sex']
相等
${sex eq "男"} 
不等
${sex ne "男"} 
小于
${base lt 10 } 
大于
${base gt 10 } 
小于等于
${base le 10 } 
大于等于
${base ge 10 } 
并且
${true and false } 
或者
${true or false } 
非
${ not (10>5) } 
判断空 : ${empty map}
判断空 : ${map==null}
判断相同 : ${ sex eq "男" }
判断相同 : ${ sx==97 } char类型只能用数字比较
三元运算符 : ${2>1?true:false }
运算符 : 1.${true and false } 2.${true or false} 3.${10 lt 5} 4.${ 10 gt 5 } 5.${not false }
EL表达式数据回显
<input type="radio" name="sex" ${sex eq '男'?'checked':'' }> 男
<input type="radio" name="sex" ${sex eq '女'?'checked':'' }> 女
五.JSTL表达式
1.导入jstl标签库
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
2.单个条件
<c:if test="${sex eq '男' }">
我是男人
</c:if>
3.多个条件
<c:choose>
	<c:when test="${sex eq '男'}">
		我是个男人
	
</c:when>
	<c:when test="${sex eq '女'}">
		我是个女人
	
</c:when>
	<c:otherwise>
		我到底是什么
	
</c:otherwise>
	</c:choose>
	
4.异常处理
<c:catch var="cat">
		
		<% out.print(10/0); %>
	
</c:catch>	
	${cat}
<br/>
	${cat.message }
<c:if test="${s!=null}">
异常 : ${s}
<br/> 
异常 : ${s.message}
<br/>
</c:if>
5.赋值/取值
<c:set var="name" value="张三"></c:set>
<c:out value="${name }"></c:out>
6.删除
<c:set var="age" value="18"></c:set>
删除之前 : ${age }
<br/> 
<c:remove var="age"/>
删除之后 : ${age }
7.导入网页
<c:import url="http://www.baidu.com" charEncoding="UTF-8"></c:import>
8.跳转页面
<c:redirect url="demo02.jsp"></c:redirect>
9.循环
<c:forEach begin="1" end="10" step="1" var="s" varStatus="vs">
${s} -- ${vs.index} -- ${vs.first } -- ${vs.last }
<br />
</c:forEach>
<c:forEach begin="1" end="10" step="1" var="s" varStatus="vs">
	<c:if test="${vs.first }">
		<span style="color:red">${s }
</span>
	</c:if>
	<c:if test="${not vs.first }">
		<span style="color:blue">${s }
</span>
	</c:if>
</c:forEach>
<c:forEach begin="1" end="10" step="1" var="s" varStatus="vs">
	<c:if test="${vs.index%2==0 }">
	<span style="color:red">${s}
</span><br />
</c:if>
<c:if test="${vs.index%2!=0 }">
	<span style="color:blue">${s}
</span><br />
</c:if>
</c:forEach>
<c:forEach items="${list }" var="s" varStatus="vs">
	${s} -- ${vs.index}
<br/> 
</c:forEach>