• 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

Test 498 question relating to jsp:useBean

 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a hint ... the default scope is "page".
Does that help?
Cheers
Simon
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Thank you. I just tested this on Weblogic to see it in action, and it worked.
Thanks again Simon,
SAF
 
You can't have everything. Where would you put it?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic