小白求教关于session

Freefish1994 2016-12-07 08:15:18
为什么写好的代码在Chrome和火狐里跑时session可以持久化,在IE和Eclipse里运行就不行?
login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
SessionID:<%=session.getId() %>
<br>
<br>
IsNew:<%=session.isNew() %>
<br>
<br>
CreateTime:<%=session.getCreationTime() %>
<br>
<br>
LastAccessTime:<%=session.getLastAccessedTime() %>
<br>
<br>
MaxInactiveIntervalTime:<%=session.getMaxInactiveInterval() %>
<br>
<br>

<form action="hello.jsp" method=post>
username:<input type="text" name="username" value=<%=session.getAttribute("username") %>/>
<input type="submit" name="username" value="submit"/>
</form>
</body>
</html>
...全文
131 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Freefish1994 2016-12-07
  • 打赏
  • 举报
回复
这是hello.jsp的代码 web.xml里也配置session-timeout了
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	SessionID:<%=session.getId()%>
	<br>
	<br>
	IsNew:<%=session.isNew()%>
	<br>
	<br>
	CreateTime:<%=session.getCreationTime()%>
	<br>
	<br>
	LastAccessTime:<%=session.getLastAccessedTime()%>
	<br>
	<br>
	MaxInactiveIntervalTime:<%=session.getMaxInactiveInterval()%>
	<br>
	<br>
	Hello:<%=request.getParameter("username") %>
	<br>
	<br>
	<%session.setAttribute("username", request.getParameter("username"));
	%>
	<a href="login.jsp">重新登录</a>
</body>
</html>

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧