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

bean use

 
Kalpesh Soni
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does the JSP engine instantiate the bean ?
Is it mandatory to have no args constructor ?
what exactly is scope ?
 
Joel Carklin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The Javabean API requires a class to have a no args constructor. This is so the system is able to instantiate the bean using the instantiate() method found in the java.beans.Beans package. I assume the jsp engine uses the same method to instantiate the bean though I'm not positive.
But Yes, it is mandatory to have no args constructor
scope, as I understand it, refers to an object which holds attrubutes. Each attribute has a unique identifying name linked to an object. A javabean would be such an attribute. There are 4 kinds of scope, indicating how much access there is to the bean. for example, a bean with page scope is only visible and accessable by the jsp page which contains it. a bean with request scope is visible to the page which contains it as well as any jsp or servlet the page is forwarded to. Session scope indicaties a bean is visible to all jsps and servlets which are part of the same session and application scope means the bean is available to all jsps and servlets in the entire web application...
I think
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic