兩個(gè)頁面創(chuàng)建的ID不一樣,怎么回事?
session:
%@ page language="java" import="java.text.*"? import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
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 'session.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">
?? ?<!--
?? ?<link rel="stylesheet" type="text/css" href="styles.css">
?? ?-->
? </head>
?
? <body>
? <h1>csession內(nèi)置對(duì)象</h1>
??? <%? session.setAttribute("user_name","jinyubao");
??????? SimpleDateFormat s=new SimpleDateFormat("yyyy-MM-dd hh:ss:mm");
??????? Date? d=new Date(session.getCreationTime());
???? %>
???? 創(chuàng)建時(shí)間:<%=s.format(d) %>
???? 創(chuàng)建ID:<%=session.getId() %>
???? 用戶名:<%=session.getAttribute("user_name")%>
???? <br>
???? <a? href="session1.jsp"?? target="_blank">跳轉(zhuǎn)到session1頁面</a>
??? ?
??? <br>
? </body>
</html>
session1:
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
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 'session.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">
?? ?<!--
?? ?<link rel="stylesheet" type="text/css" href="styles.css">
?? ?-->
? </head>
?
? <body>
???? 創(chuàng)建ID:<%=session.getId()%><br>
???? 用戶名:<%=session.getAttribute("user_name")%>
??? hello world<br>
? </body>
</html>
結(jié)果:
csession內(nèi)置對(duì)象
創(chuàng)建時(shí)間:2016-11-06 10:50:25
? ? 創(chuàng)建ID:504B8B68ACB2E47830DB4EC1FE76B4DC
? ? 用戶名:jinyubao ? ?
? ? 跳轉(zhuǎn)到session1頁面
創(chuàng)建ID:B2A56A9B2F71948FEEA5EE15340C1123
? ? 用戶名:null
? ?hello world
結(jié)果創(chuàng)建的ID不一樣,怎么回事?
2016-11-06
那些meta 標(biāo)簽案例上有嗎,再看看web.xml文件是不是定義session的有效期了
2016-11-06
把你的web.xml傳給我一下
謝謝!!!!!!!!
2016-11-06
我把你的代碼粘在我的項(xiàng)目里,一切正常,看看你的web.xml吧