2020-03-24

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

<%

  pageContext.setAttribute("name","张三");

  request.setAttribute("name","李四");

  session.setAttribute("name","王五");

  application.setAttribute("name", "赵六");

%>

<h1>当前页面获取值</h1>

<%= pageContext.getAttribute("name") %>

<%= request.getAttribute("name") %>

<%= session.getAttribute("ame") %>

<%= application.getAttribute("name")%>

</body>

</html>


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

  <h1>获取四个范围的数据</h1>

  <%= 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);

%>

</body>

</html>


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

  <h1>JSP的动作标签;转发</h1>

  <jsp:forward page="/demo1/demo4">

</body>

</html>


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

<h1>demo4.jsp</h1>

<%= request.getParameter("name") %>

</body>

</html>


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

<%@ include file="Logo.jsp" %>

<%@ include file="menu.jsp" %>

<h1>Body</h1>

<%= i %>

<%@ include file="foot.jsp" %>

</body>

</html>


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

<h1>EL执行运算</h1>

<%

  pageContext.setAttribute("n1",10);

  pageContext.setAttribute("n2",20);

%>

${ n1 + n2 + n3 }

<h3>执行算数运算</h3>

${ n1 < n2 } -- ${ n1 lt n2 }<br>

${ n1 > n2 } -- ${ n1 gt n2 }<br>

${ n1 == n2 } -- ${ n1 eq n2 }<br>

${ n1 >= n2 } -- ${ n1 ge n2 }<br>

${ n1 <= n2 } -- ${ n1 le n2 }<br>

${ n1 != n2 } -- ${ n1 ne n2 }<br>

<h3>执行逻辑运算</h3>

<%

  pageContext.setAttribute("n3","30");

  pageContext.setAttribute("n4","40");

%>

${ (n1 < n2) && (n3 < n4) -- ${ (n1 < n2) and (n3 < n4) }<br>

${ (n1 < n2) || (n3 < n4) -- ${ (n1 < n2) or (n3 < n4) }<br>

${ !(n1 < n2) } -- ${ not (n1 < n2) }<br>

<h3>执行三元算</h3>

${ n1 < n2 ? "n1小于n2" : "n1不小于n2" }

<h3>空运算符</h3>

${ empty user }<br>

${ not empty user }<br>

</body>

</html>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • JSP <%@ page language="java" contentType="text/html; char...
    卡拉什尼科夫_8ca2阅读 239评论 0 0
  • 代码 <%@ page language="java" contentType="text/html; chars...
    凉栀_6e9d阅读 73评论 0 0
  • JSP & EL & JSTL (一)JSP的回顾 一、什么是JSP JSP:JavaServerPages(...
    王月坤阅读 134评论 0 0
  • JSP & EL & JSTL (一)JSP的回顾 一、什么是JSP JSP:JavaServerPages(...
    李玉贤_8e75阅读 235评论 0 0
  • JSP & EL & JSTL (一)JSP的回顾 一、什么是JSP JSP:JavaServerPages(...
    董宇浩阅读 77评论 0 0