• Post Reply Bookmark Topic Watch Topic
  • New Topic

Strange HttpSession behavior

 
Ryan McClain
Ranch Hand
Posts: 153
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am testing how HttpSessions work.

Servlet code:


I have conducted the following actions while experimenting with sessions:

OS: Windows 7 x64
Web container and webserver: Apache Tomcat 7.0.29

Browser: Internet Explorer 10
open browser
visit servlet
response: "This is a new session." (expected response)
re-visit servlet
response: "Welcome back!" (expected response)
delete cookies
visit servlet by pressing enter key on address bar
response: "Welcome back!" (unexpected response)
Conclusion: Internet Explorer 10 seems to only confirm cookie deletion upon browser restart.

close browser
open browser
visit servlet
response: "This is a new session."
repeat three steps above
response: "This is a new session."
conclusion: Container will invalidate the session and create a new one every time you close the browser window and open a new one in Internet Explorer 10.

Browser: Chrome
open chrome
visit servlet
response: "This is a new session." (expected response)
re-visit servlet
response: "Welcome back!" (expected response)

close chrome
open chrome: "Welcome back!" (unexpected response)
clear browsing data (cookies only)
re-visit servlet
response: "Welcome back!" (unexpected response)

clear browsing data (cookies only)
close browser
open browser
response: "This is a new session" followed milliseconds later by: "Welcome back!" (unexpected response, behaves like AJAX call; happens too fast for me to see what's going on)
String "This is a new session" appears first but gets replaced in the blink of an eye by "Welcome back!" (unexpected behavior)

So my question is: how do you explain the unexpected behavior I am getting from my experiment?

 
Ivan Jozsef Balazs
Rancher
Posts: 992
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firefox has a useful gadget to sniff the HTTP headers. Perusing them might shed some useful light on what is actually going on.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65520
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All modern browsers have network tools that can be used to inspect HTTP requests and responses.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!