• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Standard Action's

 
Amandeep Singh
Ranch Hand
Posts: 850
  • 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.
 
Atul Samnerkar
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: 850
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic