Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sessions within same war  RSS feed

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose we have two servlets runing inside same war on same server. When user access servlet A and create a session, he then open another tab or browser to access servlet B (session created by servlet A still exist). Inside servlet B, does

request.getSession()

return the session created by servlet A ?

 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36463
462
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,
Yes. A war (web archive) is a web application. It is intentional that they share a session. Imagine you had a login servlet and a navigation menu servlet. You'd want the navigation menu to know if the user logged in!
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes and no. In another tab of the same browser you'd get the same session, but in a different browser you'd get a different session.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!