Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:setProperty stand action and its body

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

Accordint to the JSP spec the <jsp:setProperty> and <jsp:getProperty> action tags don�t have any BODY.

For <jsp:getProperty>, for instance, this does not work fine: <jsp:getProperty ....></jsp:getProperty> (NO BODY and NO BLANK SPACE) - (ERROR).

And what about the <jsp:setProperty> ?

Enclosed is a question regarding this issue:

piblic class Bucks {

private int bucks = 0;

public int getBucks(){
return this.buck;
}

public void setBucks(int buck){
this.buck = buck;
}
}

Assuming you have a reference "employeeBean" to an instance of the EmployeeBean class declared in the sample code above, how do you set the value of "bucks" to 10000?

Choice 1 - <jsp:setProperty name="employeeBean" property="salary" value="10000"></jsp:setProperty>

Choice 2 - <jsp:setAttribute name="employeeBean" property="salary" value="<%= Integer.parseInt(10000)%>"/>

Choice 3 - <jsp:setProperty id="employeeBean" property="bucks" value="10000"/>

Choice 4 - <jsp:setValue name="employeeBean" property="salary" value="10000"></jsp:setValue>

Choice 5 - <jsp:setProperty id="employeeBean" property="salary" value="10000"></jsp:setProperty>

what is the correct answer?

Tks.
 
Vivek Kinra
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My answer is "None of the above" but you can set with
<jsp:setProperty name="employeeBean" property="bucks" value="10000"/>
 
Sridevi Singireddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Choice 1 is correct.
 
Vivek Kinra
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where is the property "salary"??
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Sorry Vivek, it was a typo.(it should be "bucks")..

Well, i also would choose "None of the above" , but there ins�t this option.

So is that incorrect, ins�t that?

I mean, The question and the option "1" are wrong right?

tks.
 
Vivek Kinra
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, they are wrong...
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
k, tks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic