File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes jsp:setProperty versus bean set method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:setProperty versus bean set method" Watch "jsp:setProperty versus bean set method" New topic

jsp:setProperty versus bean set method

Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
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" />
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?

for (int i = today; i < endOfTime; i++) { code(); }
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
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.
I agree. Here's the link:
subject: jsp:setProperty versus bean set method
jQuery in Action, 3rd edition