代码
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="UTF-8"%>
<%
pageContext.setAttribute("name","张三");
request.setAttribute("name","李四");
session.setAttribute("name","王五");
application.setAttribute("name", "赵六");
%>
当前页面获取值
<%= pageContext.getAttribute("name") %>
<%= request.getAttribute("name") %>
<%= session.getAttribute("ame") %>
<%= application.getAttribute("name")%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
获取四个范围的数据
<%= pageContext.getAttribute("name") %>
<%= request.getAttribute("name") %>
<%= pageContext.getAttribute("name",pageContext.REQUEST_SCOPE) %>
<%= session.getAttribute("name") %>
<%= pageContext.getAttribute("name",pageContext.REQUEST_SCOPE) %>
<%= application.getAttribute("name") %>
<%= pageContext.getAttribute("name",pageContext.APPLICATION_SCOPE) %>
<%
pageContext.setAttribute("name","张三");
pageContext.setAttribute("name","李四", pageContext.REQUEST_SCOPE);
pageContext.setAttribute("name","李四", pageContext.REQUEST_SCOPE);
pageContext.setAttribute("name","李四", pageContext.AALICATION_SCOPE);
%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
JSP的动作标签;转发
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
demo4.jsp
<%= request.getParameter("name") %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ include file="Logo.jsp" %>
<%@ include file="menu.jsp" %>
Body
<%= i %>
<%@ include file="foot.jsp" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
EL执行运算
<%
pageContext.setAttribute("n1",10);
pageContext.setAttribute("n2",20);
%>
${ n1 + n2 + n3 }
执行算数运算
${ n1 < n2 } -- ${ n1 lt n2 }
${ n1 > n2 } -- ${ n1 gt n2 }
${ n1 == n2 } -- ${ n1 eq n2 }
${ n1 >= n2 } -- ${ n1 ge n2 }
${ n1 <= n2 } -- ${ n1 le n2 }
${ n1 != n2 } -- ${ n1 ne n2 }
执行逻辑运算
<%
pageContext.setAttribute("n3","30");
pageContext.setAttribute("n4","40");
%>
${ (n1 < n2) && (n3 < n4) -- ${ (n1 < n2) and (n3 < n4) }
${ (n1 < n2) || (n3 < n4) -- ${ (n1 < n2) or (n3 < n4) }
${ !(n1 < n2) } -- ${ not (n1 < n2) }
执行三元算
${ n1 < n2 ? "n1小于n2" : "n1不小于n2" }
空运算符
${ empty user }
${ not empty user }