Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Jsp Property question

 
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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • 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
 
crispy bacon. crispy tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic