• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Standard Action's  RSS feed

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the following line of code appearing in a JSP page:

<jsp:setProperty name="hellobean" property="username" param="name" />

Which of the following statements regarding the above LOC is correct?

Assume that hellobean exists in the page scope and has a method: public void setName(String name).

1.If the request contains a name parameter, its value will be set into the bean.

2.If the request contains a username parameter, its value will be set into the bean.

3.If the request contains an empty String value for the username parameter, then an IllegalArgumentException will be thrown.

4.If the request contains an empty String as a value for the name parameter, then an IllegalArgumentException will be thrown.

5.None of these.

The correct answer is 5. i agree it can be. But why the anser 1 is not correct.

Please advice. This is from Enthuware.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any additional code exhibit given for this example?
The question has ambiguity on the location of the <jsp:setProperty>.

If <jsp:setProperty> is inside the <jsp:useBean> tag then it will never be invoked if the bean already exists. Hence answer 5 is correct on this assumption.

Thanks & Regards,
Atul Samnerkar
 
Amandeep Singh
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question is complete.
_________________________________________________________________________
Assume that hellobean exists in the page scope and has a method: public void setName(String name).
__________________________________________________________________________

the answer is correct based upon the fact, that it has method setName, so the property name must be name.

But as the param is already given in the question, so the answer 1 should also be correct.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!