This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I cant figure out this answer. I know a) and b) are not correct because there is no such scope as "config" and "context. Anyway, here is the question.
A Web application on startup reads global information from the database into com.ibm.ApplicationInfo JavaBean and adds the bean to the servlet context. Which of the following tags allow accessing this information from a JSP page? a) jsp:useBean id="appInfo" class="com.ibm.ApplicationInfo" scope="config" b) jsp:useBean id="appInfo" class="com.ibm.ApplicationInfo" scope="context" c) jsp:useBean id="appInfo" class="com.ibm.ApplicationInfo" d) jsp:useBean id="appInfo" class="com.ibm.ApplicationInfo" scope="application" SAF
Simon Brown
sharp shooter, and author
Ranch Hand
Joined: May 10, 2000
Posts: 1860
posted
0
Here's a hint ... the default scope is "page". Does that help? Cheers Simon
SAFROLE YUTANI
Ranch Hand
Joined: Jul 06, 2001
Posts: 257
posted
0
That's exactly the info I was looking for because I knew that for option c) there is no scope specified, therefore, I knew a default was being used, but I wasn't sure what it was. c) is therefore the answer. Thanks man, SAF
Simon Brown
sharp shooter, and author
Ranch Hand
Joined: May 10, 2000
Posts: 1860
posted
0
The jsp:useBean action looks for a named instance in the specified scope and if it is isn't there, it creates it. This means that answer (c) will try to find a bean called appInfo on the page. However, the startup process initialises the JavaBean and binds this into the servlet context. This is (if you like) a global area for the whole of your application, and is therefore accessed by using the "application" scope. Although answer (c) will compile and run, it will in fact create a new instance rather than finding the instance that has already been configured and bound to the servlet context. In short, answer (d) is correct. [This message has been edited by Simon Brown (edited August 23, 2001).]
SAFROLE YUTANI
Ranch Hand
Joined: Jul 06, 2001
Posts: 257
posted
0
Yes. Thank you. I just tested this on Weblogic to see it in action, and it worked. Thanks again Simon, SAF