• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL implicit variables

 
Anitha Srinivasan
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • 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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • 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
 
Arunabh Dash
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
refer to the specif hfsj pages

Not everybody owns it (I don't)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic