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

question on jsp:useBean

 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A jsp page need to instantiate a java bean to be used by only that page
which two jsp:useBean attribute must be used to access this attribute in the jsp page ( choose two )
1. id
2.type
3.name
4.class
5. scope
6. create

my answer
id , type( confused )
no need of scope ( default scope = page)
whats ur answer
 
Sai Patnala
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the bean has to be instantiated (doesnt exist in page scope) then id and class must be present.
With type alone, you cannot instantiate a bean. It will find it if exists in the scope.

You are right about page being default scope.
 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody explain which option will come
class or type
please explain it clearly
i am not able to understand this concept
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'type' is used to locate an existing object., and does not create a new instance if the object is not found.
When not found, InstantiationException is thrown.
When found, if it is not a type or subtype of the class or interface specified in 'type', ClassCastException is thrown.

'class' is used to create a new instance of a bean when not found.
 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so answer must be

id , class

am i right
 
Priya Jothi
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes..exactly!!

Regards,
Priya.
 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is written

we can choose any combination

id , class
or
id , type

am i right
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

it is written

we can choose any combination

id , class
or
id , type

am i right



You can use "id , type" if the bean already exists in page scope
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic