Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

beanName

 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem

You want to use a bean that is stored in com/enthu/GUI.ser file. Which of following statements correctly defines the tag that accesses the bean?


Options

Select 1 correct option.

1 <jsp:useBean id="pref" name="com/enthu/GUI.ser" />

2 <jsp:useBean id="pref" name="com.enthu.GUI" />

3 <jsp:useBean id="pref" type="com/enthu/GUI.ser" />

4 <jsp:useBean id="pref" beanName="com.enthu.GUI" type="com.enthu.GUI"/>

5 <jsp:useBean id="pref" class="com.enthu.GUI.ser" />



The answer is 4. I have no idea about the question. Please can somebody explain it.
 
Mohd Fuzail
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bean that is stored in com/enthu/GUI.ser file


Here the package structure is provided. so the fully qualified name for this class will be com.enthu.GUI

Not sure about this .ser extension


beanName="{package.class | <%= expression %>}" type="package.class"

Instantiates a Bean from either a class or a serialized template, using the java.beans.Beans.instantiate method, and gives the Bean the type specified in type. The Beans.instantiate method checks whether a name represents a class or a serialized template. If the Bean is serialized, Beans.instantiate reads the serialized form (with a name like package.class.ser) using a class loader. For more information, see the JavaBeans API Specification.

The value of beanName is either a package and class name or an Expression that evaluates to a package and class name, and is passed to Beans.instantiate. The value of type can be the same as beanName, a superclass of beanName, or an interface implemented by beanName.

The package and class names you use with both beanName and type are case sensitive
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Fuzail. It really helped me. Can someone has an idea about the ".ser" extention.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic