Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

<jsp:useBean>  RSS feed

 
Marcelo DeOliveira
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is from Nikos' Mock Exam question 54

Consider this code and that there is no attribute in the request object.





What is the output of hello.jsp?

a. Hello !!
b. Hello Niko!!
c. An Exception is thrown at runtime

The answer is b, but I don't know why.

Anybody can explain why?
Thanks,
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37261
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marcelo,
The use bean creates a new bean in the request (since one doesn't already exist. It then sets the name to Niko. At this point, we have a bean with the name set in the request.

Then expression language is used to print it out. EL looks through the scopes for a bean named person. It finds one in the request scope and then retrieves it, printing out the name of Niko.
 
Marcelo DeOliveira
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Person class is not a Bean! Correct? Does not follow the set/get attribute bean rules.
Does the useBean still recognizes it as a bean?
thanks,
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marcelo DeOliveira wrote:Does not follow the set/get attribute bean rules.

How so?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!