JSP Session id changes on every refresh

别等时光非礼了梦想. 提交于 2019-12-24 06:39:49

问题


I am facing a problem that the JSP session ID value changes on every Browser refresh on the development server, but I do not know what is the reason.

My JSP sessiontest.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
</head>
<body>
<a href="sessiontest.jsp?id="><%=session.getId()%>  
</body>

My browser is Firefox 5,and the server is Tomcat 6.

I have tested this JSP on http://localhost:8080/SessionTest/sessiontest.jsp?id=B68DA1C526F083800AED9D83AF1C8BC0, everything is fine and session ID remains the same after refreshing. But if I deploy the war file on the development server, (http://www.company.com/subdomain/SessionTest/sessiontest.jsp), the session ID value changes on every refresh. Any helps would be greatly appreciated. Thanks.


回答1:


I suspect your company website is not running with only Tomcat server but has an Apache web server fronting it. This is standard practice for corporate web sites.

The Apache web server has some settings and config for mod_proxy for ProxyPassReverse to maintain the session between browser <-> Apache <-> Tomcat.

Can you check with your admin team on that?



来源:https://stackoverflow.com/questions/6704686/jsp-session-id-changes-on-every-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!