• 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

Question 60 - Final mock exam HFSJ

 
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question is


When comparing servlet intialisation parameters to context initialisation parameters, which are true for both? (Choose all that apply.)

A. In their respective DD tags, they both have a <param-name> and a <param-value> tag.
B. Their repective DD tags are both placed directly under the <web-app> tag.
C. Their respective methods used to retrieve intialisation parameter values are both called getInitParameter.
D. Both can be directly accessed from a JSP.
E. Only changes to context initialisation parameters in the DD can be accessed without redeploying the web application.



The answers given are A+C, I think the answers should be A,C+D. The reason given for D being incorrect is


Option D: only context params can be directly accessed from JSPs



To me this is wrong, JSP has access to both application (ServletContext) and config (ServletConfig) implicit objects.
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the word that is tricky here is "directly accessed", which I guess here means directly by using parameter name. For example any Attribute can be directly accessed by its name ${attrName}. but you cant do ${initParamName}.
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Option D is not correct and they have given a valid reason "only context params can be directly accessed from JSPs".
If you want to access servlet initialization parameters inside a JSP it is a tricky task. For this you need to treat your JSP as a servlet and also access it as a servlet in browser.
See this thread https://coderanch.com/t/177239/java-Web-Component-SCWCD/certification/init-param-jsp
 
Paul Statham
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok you're right I suppose the method I was talking about would be something like



Which I suppose isn't direct. But if we were to use the EL example you've given it would still be



Edit: Ignore just noticed that initParam is actually a <context-param> not a <init-param>
 
I knew that guy would be trouble! Thanks tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic