• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubts on session management mock questions

 
rachna jain
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

This is regarding question no 15(page 279 HFS 2nd edition)

It says correct answers are A and C but according to me it should be only A

When session time out how come ValueUnbound method will be called.


Please clarify.


another doubt in q no-17(page no 280)

Answer is A but i think it should be F

Please clarify soon as i am planning to give SCWCD in coming weekend.


I am new to java ranch please let me know if its the correct way of posting in a forum.

Thanks
 
Andriy Pererva
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Rachna!

Regarding question #15:
Look at the J2EE API, description of the HttpSession.invalidate() method says:
"Invalidates this session then unbinds any objects bound to it."
So it is quite reasonable for valueUnbound handler to be invoked.
 
Narendhiran Nagarajan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Q15,
The HttpSessionBinding listners are usually implemented on the attribute classes, which are used to notify when the attribute is added to or removed from the session. When the session is destroyed it implicitly mean that the attributes are removed from that particular session. So, the valueUnbound method will be called.
 
rachna jain
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot it cleared my doubt..i got confused .It will surely unbinds its attributes on termination
 
Narendhiran Nagarajan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Q17,
I hope, you are saying the answer as F, cause after invalidating the session, we cant access the attributes that are associated with the session.(These all happen at runtime check)
But look carefully at line 16, you cant create a session like this. Thats why its throwing the compilation error.
 
rachna jain
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding Q 17 on line 16 its creating session object please clarify if i remove req parameter then this will be okay right?

otherwise yes its wrong
 
Narendhiran Nagarajan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No you cant create a session llike that. You create like
1. HttpSession session = request.getSession();
2. HttpSession session = request.getSession(true);
3. HttpSession session = request.getSession(false);

Note: 1 and 2 are same.But 3 will not create a new session.
 
rachna jain
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic