• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Attributes, Session and ServletContext

 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
https://coderanch.com/t/168243/java-Web-Component-SCWCD/certification/answer-HeadFirst-Servlets-JSP
 
reply
    Bookmark Topic Watch Topic
  • New Topic