• 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

EL implicit variables

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following implicit variables can be used to retrieve the values added to the ServletContext object? select one.

A.initParam
B.applicationScope

The ans is B. But I thought it was A. Can anyone explain it?

Thanks,
Anitha
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It says "the value added", so I think that it means values added with setAttribute, not init parameters. That's confusing though.
 
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simple
initParam uses only for to retrieve context initialization parameters.
like ${initParam.anyParamName}

applicationScope uses only for retrieving application scope attributes.

<%
request.setAttribute("name",new String("My Name is Anitha");
application.setAttribute("name",new String("My Name is Sreeraj"));
%>

${name}
${applicationScope.name}
 
Anitha Srinivasan
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If we add the value thro' context init parameters in web.xml then the ans is initParam ? If we set the attribute then the ans is applicationScope? How do you make the difference?
pls explain.
Thanks,
Anitha
 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If we add the value thro' context init parameters in web.xml then the ans is initParam ? If we set the attribute then the ans is applicationScope? How do you make the difference



please go to the HFSJ page that expalins the 'initParam' EL implicit object.
the bos at the side of the description, clearly states the the initParam object is used to retrive context init paramaeters and not to retrieve init parameters as the name sugests


now lets take the other part -

if you want to retirve a property of a ServletContext / Request / HttpSession object then in that case you need to use the applicationScope / requestScope / sessionScope EL impliciats objects

There is deffeernce betweeen property of ServletContext and a attribut stored in the context scope ! get the differnce ?

hth
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ,
Take it like ... Both are Map . initParam takes are of those which are being mentioned in the DD . But in the JSP if you are adding soming attribute to application scope then you must retrive it using applicationScope .

I am not sure but it will be using two differents Maps to deal with those which is mensioned in the DD and those attributes which are added to implicit object application .
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please dont confuse guys.
refer to the specif hfsj pages - it has everyting sufficinet enough to explain.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

refer to the specif hfsj pages


Not everybody owns it (I don't)
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic