• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jsp Property question

 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then which is the correct answer for this question.
Anyone tell me please
 
reply
    Bookmark Topic Watch Topic
  • New Topic