The reason you can't see the difference is that you are obviously comming from a
programming background and not a web page development background ;-)
One reason for using beans is that any programming can be taken away from then
html gurus and left to programmers to do it properly :-)
But realy the point of JSP's is to help you seperate the logic from the display.
Stuff like " clock.getDayOfMonth() " requires a html person to know about the
underlying programming logic in the bean.
What I would sugest is that you create your bean, document it, create all the
beaninfo stuff and then all a html editor would need to do is read the docs for
your bean, find out that it has a property called "dayOfMonth" and "year"then use
the standard <jsp:getProperty> or <jsp:setProperty> tags (only two extra tags for
html man to learn, so there's a benefit ;-)
eg:-
<%@ page import="calendar.jspCalendar" %>
<html>
<jsp:useBean id="clock" class="calendar.jspCalendar" >
<jsp:setProperty name="clock" property="*" />
</jsp:useBean>
<ul>
<li>Day: <jsp:getProperty name="clock" property="dayOfMonth" />
<li>Year: <jsp:getProperty name="clock" property="year" />
</ul>
</html>
hope that explains a reason why you should use beans, ie seperate the programming
logic from the presentation logic.
PS I noticed that on JSP 1.1 Beta Syntax card that I'm currently using the
<jsp:getProperty /> tag is missing perhaps I'd better see if there is a new one.
(sigh!)
Karl
Patrick Regan wrote:
> I am trying to determine what the benefits are to using beans over just
> an ordinary class. From the little that I know, I don't see the
> benefit.
>
> Take the calendar example for a bean (here is the JSP code) :
>
> <html>
> <jsp:useBean id="clock" class="calendar.jspCalendar"/>
> <ul>
> <li>Day:<%= clock.getDayOfMonth() %>
> <li>Year:<%= clock.getYear() %>
> </ul>
> </html>
>
> Versus just an ordinary server-side java class (here is the JSP code):
>
> <html>
> <% JspCalendar clock = new JspCalendar() %>
> <ul>
> <li>Day:<%= clock.getDayOfMonth() %>
> <li>Year:<%= clock.getYear() %>
> </ul>
> </html>
>
> Can someone give me an idea of why I should use beans over a regular
> server-side class?
>
> Thanks,
> Patrick Regan
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html