Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:setProperty versus bean set method

 
Winston Smith
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Assume I have a bean called Dog, with an attribute called age.
When assigning a value to age, what are the differences between using:
1.) <jsp:setProperty name="Dog" property="age" value="12" />
and
2.) Dog.setName("12");
I realize when using (2), you have to include the bean in the jsp page, but are there any other differences?
Thanks,
WS
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only difference is that with 1), the bean will be created automatically if it doesn't exist in the scope that you defined in your jsp:useBean tage.
Raffi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic