This question comes from the end of chapters 6 session management of head first servlet and jsp:
Which statements about session attributes are true?
One of the correct answer is: "Attributes bound into a session are available to any other servlet that belongs to the same ServletContext".
I am not quite sure why this answer is correct. My understanding is that a session attribute is only available to a servlet if the session is passed into the servlet in the request parameter. That is, a servlet can not just grab a attribute from any session it wants to. Can someone clarify?
No. Attributes of a session will not be available to any app in the same ServletContext unless that servlet also uses the same Session. You tell the complete questions and answers. One more thing, an attribute with Session scope wont be available to all other apps which are sharing same Request object. For that you need to explicitly put the attribute in the Request attribute or those apps also have to use the same session. Got it?