This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Session Id Problem

 
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.
 
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...
 
    Bookmark Topic Watch Topic
  • New Topic