• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Doubt on chapter-6 Q-7 HFSJ

 
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
 
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
 
Do you want ants? Because that's how you get ants. And a tiny ads:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic