• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Attributes, Session and ServletContext

 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading HF on page 267, question 7. I had a look at the errata and this question is not there, so I'd like to know...

For question 7 the book gives as correct also answer C (Attributes bound into a session are available to any other servlet that belongs to the same ServletContext).

Now my understanding of ServletContext, is of an object at the web-app level, am I right? Because an application may have different sessions (teoretically one per user), the attributes bound to session A, let's say, are not available to session B, while an attribute bound to the ServletContext for the web-app is available from all sessions. If servletA is running in session A, and servlet B (still belonging to the same ServletContext as servlet A) is running in session B, servlet B won't have access to the attributes stored in session A.

Am I wrong?
 
Roger Yates
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done for checking the errata first.
Next thing is to do a search on the forum (took me a while to spot the Search button - top right of the page).
Try this:
http://www.coderanch.com/t/168243/java-Web-Component-SCWCD/certification/answer-HeadFirst-Servlets-JSP
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic