sessionDemo01.jsp
session范围,:只保留一个用户信息
<%
session.setAttribute("name","MLDN");
session.setAttribute("password","LXH");
%>
<jsp:forward page="sessionDemo02.jsp"/>
sessionDemo02.jsp
<%
//当前页可以取得
String name= (String)session.getAttribute("name");
String password=(String)session.getAttribute("password");
%>
<h1>name:<%=name%></h1>
<h1>password:<%=password%></h1>
<a href="sessionDemo03.jsp">sessionDemo03.jsp</a>
sessionDemo03.jsp
<%
//当前页可以取得
String name= (String)session.getAttribute("name");
String password=(String)session.getAttribute("password");
%>
<h1>name:<%=name%></h1>
<h1>password:<%=password%></h1>
跳转到:
sessionDemo02.jsp页面输出为:
name:MLDN
password:LXH
再按超链接: sessionDemo03.jsp