1
votes

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
Does the problem only occur in your browser? Any cookie blockers installed? Where do you create the session?home

1 Answers

3
votes

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?