This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question 60 - Final mock exam HFSJ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question 60 - Final mock exam HFSJ" Watch "Question 60 - Final mock exam HFSJ" New topic
Author

Question 60 - Final mock exam HFSJ

Paul Statham
Ranch Hand

Joined: Dec 05, 2008
Posts: 40
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.
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

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}.


Piyush
Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
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 http://www.coderanch.com/t/177239/java-Web-Component-SCWCD/certification/init-param-jsp

-Varun -
(My Blog) - Online Certifications - Webner Solutions
Paul Statham
Ranch Hand

Joined: Dec 05, 2008
Posts: 40
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Question 60 - Final mock exam HFSJ
 
Similar Threads
HSFJ Mock exam doubt
HFSJ Mock Exam question 60
HFJS (V2) Final Mock Question 60 is wrong?
Question 60 (Head First)
HFSJ 2nd edition - Final Mock Exam incorrect answers!?