• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session Id Problem  RSS feed

 
Mahi Ranga
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

This is my code.
public class SessionIdServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
HttpSession session = request.getSession();
String id = session.getId();
pw.println("Session Id is : " + id);
System.out.println(id);
}
}
when i am calling this servlet through Internet Explorer that time i am getting one session id and open one more Internet Explorer and run this servlet that time i am getting different Session Id.
But my problem is this is not working like that in Google Crome.

Advanced Thanks.

Regards,
MahiRanga.
 
olivier dutranoit
Ranch Hand
Posts: 81
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats normal.

Thats because not all browser work the same. For example, firefox will always (default) share its active session with other firefox browsers on the same machine. internet explorer doesn't (or didn't, i don't know about the new versions...).

In your case, every time you start internet explorer, all the "browser" sessions on the machine will be separated from each other. And probably, chrome will do the same as firefox, and every started chrome browser on the machine will use the same session (cookies etc...)

of course, this behaviour can be configurated in the configuration of each browser...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!