• Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpSession will be closed automatically after the completion of httpRequest

 
Rithanya Laxmi
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am getting HttpSession from httpServletRequest of the doFilter() like

HttpSession session = httpServletRequest.getSession();
User user = new User();
user.setName("Bob")
session.setAttribute("USER", user);
...

...

1) Here once the request is completed whether we need to explictly remove the attribute from the session and it is internally taken care when the request is complted by closing the session?
2) Similarly whether this will create a problem in cluster env, in handling session replication across various boxes as the session instance needs to be replicated across boxes?

Please clarify.

Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Attributes in the session are intended to stay alive across requests. If you don't want that, don't put data there. You can use request.setAttribute() instead which does automatically get removed after the HTML is sent back.

2) It could. IF you are using session replication, more work needs to be done the more data you have.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!