How to differentiate sessions in browser guides?

Asked

Viewed 128 times

2

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

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 (testpage.jsp), implement this file in 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 (localhost/context1/testpage.jsp), type 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 seems that this does not happen, but it is in the cache, update the second tab.

  • "FF, IE7 or Opera" - Why would a dinosaur like IE7!?

  • look, a friend in college a 20h course of IE7 and have accepted @Victorstafusa so for some it is not so dinosaur rs

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.