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

Jsp Property question

 
Dinesh Tahiliani
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A bean with a property color is loaded using the following statement
<jsp:usebean id="fruit" class="Fruit"/>
What happens when the following statement is executed. Select the one correct answer.
<jsp:setProperty name="fruit" property="*"/>
A.This is incorrect syntax of <jsp:setProperty/> and will generate a compilation error. Either value or param must be defined.
B.All the properties of the fruit bean are initialized to a value of null.
C.All the properties of the fruit bean are assigned the values of input parameters of the JSP page that have the same name.
D.All the properties of the fruit bean are initialized to a value of *.

Answer : C

Can anyone explain me this
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using "*" in the "property" attribute of the setProperty tag will scan all request parameters, and try to set them in the bean (see JSP.5.2 jsp:setProperty> in the JSP specification). For example, let's say you have two request parameters : name=orange&taste=bitter. setProperty will try to call setName("orange") and setTaste("bitter") in the Fruit bean. If these properties do not exist, they'll be ignored.


Now, I don't like the phrasing of answer C. It implies that a form has been submitted. I would have written :
C.All the properties of the fruit bean are assigned the values of request parameters that have the same name.
 
Dinesh Tahiliani
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then which is the correct answer for this question.
Anyone tell me please
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic