Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about implicit objects

 
air lulu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
question:
Which of the following implicit objects can you use to store attributes that need
to be accessed from all the sessions of a web application? (Select two)
a application
b session
c request
d page
e pageContext

what is the answer?
i think the answer is a,d,e. but the question told that just two.
whick answer i chosse is wrong?
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a is correct as it is accessible from everywhere.

d is correct as these attributes will be available to all the sessions.

e is incorrect as there is no such scope.
 
air lulu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question is asking "implicit objects ",not scope.
pageContext is implicit objects.
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I was wrong on that...
then the answer would be a and e.

see this link

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPIntro7.html

Well, if this time I am wrong then please tell me how we can use page implicit object to access the attributes.
 
air lulu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how pageContext store attributes that need
to be "accessed from all the sessions" of a web application?
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think pagerContext is right because using pageContext you
can store attributes in the application scope indirectly
pageContext.setAttribute("userName","admin",PageContext.APPLICATION_SCOPE)

hence even pageContext is a valid answer
 
Sumeet Raheja
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that Right ..Correct Answer is application and pageContext are only implicit object where one can store attribute , which will be availabe from any part of Application
 
Edmund Yong
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the web application is distributed on two JVMs, then there will be two different servlet context objects, one on each JVM. Attributes that are set on one servlet context in one JVM may not be propagated to the servlet context in the other JVM. So how can answer (a) be correct?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic