Well, since you didn't like my first idea, I came up with this JSP demo. This is kind of a hack, but it works. To check, copy and paste. Browse the first JSP. It will start the session and set the inactive interval. After redirecting, click the "Update" button in your browser. No matter how you request the second JSP, the current session will die.
test1.jsp
<%
session.setMaxInactiveInterval(20); //for easy testing
response.sendRedirect("test2.jsp");
%>
test2.jsp
<%@ page session="false" import="java.util.*" %>
<%
HttpSession session = request.getSession(false);
if(session == null){
out.print("Error, No Session!");
return;
}
long creationTime = session.getCreationTime();
long now = new Date().getTime();
long lastAccessedTime = session.getLastAccessedTime();
int oldInterval = session.getMaxInactiveInterval();
int inactivePeriod = (int)(now - lastAccessedTime)/1000;
session.setMaxInactiveInterval(oldInterval - inactivePeriod);
int newInterval = session.getMaxInactiveInterval();
%>
<html>
<body>
session id is <%=session.getId()%>
<br/><%=creationTime%> = creationTime
<br/><%=lastAccessedTime%> = lastAccessedTime
<br/><%=now%> = now
<br/><%=oldInterval%> = oldInterval in seconds
<br/><%=inactivePeriod%> = inactivePeriod
<br/><%=newInterval%> = newInterval in seconds
</body>
</html>