Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on chapter-6 Q-7 HFSJ

 
muthu kumaran
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I have a doubt on Q7 of chapt 6..
Among the answers listed for the question

Which stmt about session attributes are true ?

Option C , which says
Attributes bound into a session are available to anyother servlet that
belongs to the same ServletContext

is mentioned as a correct statement.

I think this is not true

If not can anyone clarify it ??


muthu
 
Mat Williams
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Muthu,

What this is saying is that any servlet in a ServletContext is able to get and set the attributes in a session that has been created by a servlet in the same ServletContext. In simpler terms this means any servlet defined in the web.xml file can read attributes from the session that another Servlet defined in the same web.xml file has saved to the session. Or to put it another way it is asking if a servlet can access the properties of a session that have been set by a different servlet in the same web application.

The answer is yes they can - any Servlet in a given ServletContext can access any attribute set in the session by any other servlet in the same ServletContext

Mat
 
muthu kumaran
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mat,
Thanks for u'r reply. So ,in a wider sense all servlets in a servlet context can access the session attributes provided the request is from the same client..


muthu
 
Mat Williams
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Muthu,

So ,in a wider sense all servlets in a servlet context can access the session attributes provided the request is from the same client..


Yep thats it. In fact when you do a getSession from any servlet in the same ServletContext you should get the same Session object back. Same Client = same session (provided it has not timed out or been destroyed etc)

Mat
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic