![]() |
JBridge: Certification Question Of The Day |
| JBridge Home >> Certification Questions >> Question for Sunday May 18th 2003 | Sunday May 18th 2003 |
|
Which of the following are appropriate ways to set up information that is meant to be available anywhere within a given web application? (2 correct answers) A <servlet>
<servlet-name>InitialisationServlet</servlet-name>
<servlet-class>uk.co.jbridge.servlet.Initialisation</servlet-class>
<init-param>
<param-name>initFile</param-name>
<param-value>initFile.ini</param-value>
</init-param>
</servlet>
B <context>
<init-param>
<param-name>initFile</param-name>
<param-value>initFile.ini</param-value>
</init-param>
</context>
C Within servlet code: ServletContext sc = getServletContext();
sc.setParameter("initFile", "initFile.ini");
D <context-param> <param-name>initFile</param-name> <param-value>initFile.ini</param-value> </context-param> E <servlet>
<servlet-name>InitialisationServlet</servlet-name>
<servlet-class>uk.co.jbridge.servlet.Initialisation</servlet-class>
<context-param>
<param-name>initFile</param-name>
<param-value>initFile.ini</param-value>
</context-param>
</servlet>
F Within servlet code: ServletContext sc = getServletContext();
sc.setAttribute("initFile", "initFile.ini");
Page down for the answer... The AnswerD and F are the appropriate ways. Answer D shows the correct way to embed a context parameter within the web.xml deployment descriptor. Answer F shows how to set up a context-level attribute. The ServletContext is the appropriate scope for information available to a whole web application. |
EMail: dbridgewater@jbridge.co.uk
Phone: +44 (0)1943 877414
Fax: +44 (0)1943 877414
Mail: David Bridgewater, Willow Dene, Bradford Road, Menston, Ilkley, West Yorkshire, LS29 6ED, UK
Copyright © 2003 David Bridgewater. All rights reserved.