How to differentiate the sessions in the browser tabs?

2

In a web application implemented in Java using JSP and Servlets, if I store information in the user session, this information is shared from all the tabs of the same browser. How to differentiate sessions from browser tabs?

In this example:

<%@page language="java"%>
<%
String user = request.getParameter("user");
user = (user == null ? (String)session.getAttribute("SESSIONS_USER") : user);
session.setAttribute("SESSIONS_USER",user);
%>
<html><head></head><body>
<%=user %>
<form method="post">
User:<input name="user" value="">
<input type="submit" value="send">
</form>
</body></html>

Copy this code to a JSP page (% with%), deploy this file to an existing context of a web application on the server (I use Apache Tomcat), and then open a browser (FF, IE7, or Opera) using the correct URL ( testpage.jsp ), enter your name in the entry and submit the form. Then open a new tab in the same browser, and then you can see your name (get from the session) in the new tab. Be careful with the browser cache, sometimes it does not seem to happen, but it's in the cache, update the second tab.

    
asked by anonymous 08.01.2018 / 18:58

0 answers