• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification on HFJS question

 
Abhishek Sharma
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

I noticed one question in session management chapter of HFJS, it states

Which statements about session attributes are correct.

one of the correct answers includes
Attributes bound into a session are available to any other servlet that belongs to the same ServletContext.

please refer page 267
question 7
Topic session management

Question:
Is the statement given is correct??

Please clarify


Thanks in advance,
Abhishek
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, its correct

If you place something in session, it will be available to all the servlets under same servlet context.

You can try it by placing something in Session in one Servlet and then try to retrieve that value in another Servlet, you will get the value successfully.
 
Abhishek Sharma
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the point..

Thanks Ali
 
Vinod Iyer
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attributes bound into a session are available to any other servlet that belongs to the same ServletContext !!

i think should be


Attributes bound into a session(s1) are available to any other servlet that belongs to the same ServletContext via same session(s1) !!
[ February 22, 2007: Message edited by: Vinod Iyer ]
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have my HFSJ with me right now, but the statement is not completely true. The attributes will only be accessible in a servlet if the request object within the servlet's running method participates in the session that contains the attributes.
 
Saurabh Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a little confusion here:
Attributes bound into a session are available to any other servlet that belongs to the same ServletContext


I agree that an attribute bound to a session is available to other servlet(s) belonging to same ServletContext and participating in session.
But what if the attribute implements Serializable and the session migrates to other JVM. In that case, might that attribute be available to servlets belonging to new ServletContext?

Please help me clear this doubt.

Thanks and regards,
Saurabh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic