<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.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">
<style type="text/css">
.odd { background-color: #0094ff }
.even { background-color: #ccc }
</style>
</head>
<body>
<%------------------------------------------------------------------------------%>
<%
request.setAttribute("name", "tom1");
request.setAttribute("html", "<font color='red'> 哈哈</font>");
%>
<%-- 输出标签 --%>
<c:out value="abc"></c:out>
<br />
<c:out value="${requestScope.name1}" default="tom"></c:out>
<c:out value="${html}" escapeXml="false"></c:out>
<%------------------------------------------------------------------------------%>
<%--<c:set>标签 操作域 --%>
<c:set var="nam" value="jeyy" scope="request"></c:set>
<c:out value="${nam}"></c:out>
${requestScope.nam}
<%------------------------------------------------------------------------------%>
<%--<c:remove>标签 删除标签 --%>
<c:remove var="name" scope="request" />
${requestScope.name}
<%------------------------------------------------------------------------------%>
<%--<c:catch>标签 捕获异常(可能出现异常的代码用catch标签包裹起来) --%>
<c:catch var="e">
<%
int i = 10 / 0;
%>
</c:catch>
${pageScope.e.message}
<%------------------------------------------------------------------------------%>
<%-- <c:if test="">标签 相当于 if-else --%>
<c:set var="num1" value="10" scope="page"></c:set>
<c:set var="num2" value="100" scope="page"></c:set>
<c:if test="${num1>num2}" var="result" scope="page">
num好大啊?
</c:if>
判断结果boolean类型:${pageScope.result}
<%------------------------------------------------------------------------------%>
<%--<c:choose> 选择标签 --%>
<c:set var="num3" value="10" scope="page"></c:set>
<c:set var="num4" value="100" scope="page"></c:set>
<c:choose>
<c:when test="${num3>num4}">
无极天下
</c:when>
<c:otherwise>
武练巅峰
</c:otherwise>
</c:choose>
<%-------------------------------------------------------------%>
<%
List<String> list = new ArrayList<String>();
list.add("tom");
list.add("chen");
list.add("xiaoman");
list.add("jack");
list.add("rose");
request.setAttribute("list", list);
%>
<%--<c:foreach>遍历标签 每次遍历都会产生一行tr 把要遍历的行写在标签内 --%>
<table border="1" align="center" bordercolor="red">
<tr>
<%--用于设置表头--%>
<th>姓名</th>
<th>是否是集合中的第一个元素</th>
<th>是否是集合中的最后一个元素</th>
<th>显示当前便利的索引</th>
<th>显示当前遍历的计数</th>
</tr>
<c:forEach items="${requestScope.list}" var="name" varStatus="st">
<tr class="${st.index%2==0?"even":"odd" }">
<td>${pageScope.name}</td>
<td>${pageScope.st.first}</td>
<td>${pageScope.st.last}</td>
<td>${pageScope.st.index}</td>
<td>${pageScope.st.count}</td>
</tr>
</c:forEach>
</table>
<%------------------------------------------------------------------------------%>
<%-- 数数功能:用于实现分页效果--%>
<table border="1" align="center">
<th>值</th>
<c:forEach begin="1" end="10" step="1" var="num">
<tr>
<td>${num}</td>
</tr>
</c:forEach>
</table>
<%------------------------------------------------------------------------------%>
<%--<c:url>生成URL的标签 --%>
<c:url context="/day11_00_jsp" value="/AServlet" var="url" scope="page">
<c:param name="name" value="tom"></c:param>
<c:param name="age" value="19"></c:param>
</c:url>
${pageScope.url}
<%------------------------------------------------------------------------------%>
<%--<c:redirect>重定向标签 --%>
<c:redirect context="/day11_00_jsp" url="/AServlet">
</c:redirect>
</body>
</html>