Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whats the diff

 
anshu sahai
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i am preparing for scwcd.i am reading hfsj book i am not clear with this plz some one explain me
<jsp:usebean id ="person" class = "foo.person" scope="request">
<jsp:setproperty name ="person" property=name value=fred"/>
</jsp:usebean>

and
<jsp:usebean id ="person" class = "foo.person" scope="request"/>
<jsp:setproperty name ="person" property=name value=fred"/>

what is the difference between two.
 
joko mujoko
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the different is, in the statement
<jsp:usebean id ="person" class = "foo.person" scope="request">
<jsp:setproperty name ="person" property=name value=fred"/>
</jsp:usebean>

because <jsp:setproperty name ="person" property=name value=fred"/>
in the body of <jsp:useBean.. then person.name is just assigned by Fred if bean person is not exist. imagine if person.name is already set from previos JSP or servlet and no need to overwriiten by new value.


But in this statement,
<jsp:usebean id ="person" class = "foo.person" scope="request">
<jsp:setproperty name ="person" property=name value=fred"/>

person.name is always write by 'Fred'. What happen if in person.name is already assign by 'Anshu'?. it will overwritten also, so yu will never get 'Anshu' in person.name after the statement.


Hope this help Anshu..

Joko
 
anshu sahai
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic