Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in jsp:useBean

 
Shanmugam Karthikeyan
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume the following class and interface, defined in different source files and same package, will the following JSP tag work?

jsp:useBean id="mobile" scope="session" class="Device" type="Phone"

1. Yes. The phone class implements correctly the Device interface.
2. No. The class attribute Device is not a superclass of the class Phone.
3. No. The attribute class and type cannot be used together.
4. Yes. The useBean Tag is implemented correctly.
5. No. An InstantiationException is thrown at compile-time.

The answer given is 2.But for me i think the answer 5 is also correct , because we cannot create an instance of an interface.

Pls let me know whether iam right or wrong...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may be right. This is what the spec says :

If the class attribute is used for a Java type that cannot be instantiated as a JavaBean,
the container may consider the page invalid, and is recommended to (but not required to) produce a fatal translation error at translation time, or a java.lang.InstantiationException at request time.

With Tomcat 5.x, a translation error occurs.
But who what happens with another container...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic