One fantastic feature of bean is it allows Visual IDE to provide visual
design feature, I think this is the major advantage of javabean spec came
out.
Tool like IBM Websphere Studio will provide this feature I guess. It helps
increase productivity, even a lot of 'good' html programmers don't agree,
they would prefer coding by hand :)
Regards,
Ng Kien Kiong.
> >
> > Hi,
> >
> > I'm wondering what's the use of beans with JSP. In my (humble) opinion,
> > beans are useless... everything I can do with beans can be done with
> > "normal" java objects as well.
>
>In general, it's much easier to maintain a web application if you keep
>the code in the JSP pages to a minimum (see the archives for tons of
>discussions about this). Using beans, and custom actions, is a good way
>to achieve this goal.
>
> > For example,
> >
> > <jsp:useBean id="myBean" class="MyBean" scope="session">
> >
> > can easily be replaced by
> >
> > <% MyBean myBean = new MyBean();
> > session.put("myBean", myBean); %>
>
>No, <jsp:useBean> only creates an instance if the bean can't be
>found in the specified scope.
>
> > Moreover, beans obviously have some disadvantages:
> >
> > - the syntax is very awkward. Instead of writing <jsp:setProperty
> > name="myBean" property="prop" value="val"> I can write
> > myBean.setProp("val"), which seems much smoother
> > - Construction of beans seems to be limitied to using the
> > (argument-less) standard constructor. Constructors with arguments are
> > not supported.
> > - Using <jsp:setProperty>, only String properties can be set. If I want
> > to set any other properties, I have to access the bean directly anyway.
>
>No, <jsp:setProperty> can be used to set properties of any type (see the
>JSP specification for details).
>
> > So, I'd really like to know what's the big deal about beans? I would
> > rather write my JSP pages without using beans, but I'm wondering if I'm
> > missing something? What's the reason that beans were introduced to JSP
> > in the first place? Are there any situations in which the use of beans
> > provides a real advantage over the "traditional" approach?
>
>The main reason to use beans is to minimize the amount of code in the
>JSP pages, see above. I look at beans primarily as carrier of information,
>for instance all information about a customer. The bean can be created
>by a servlet, e.g. getting the info from a database, and then passed to
>a JSP page where the properties are displayed using <jsp:getProperty>.
>
>--
>Hans Bergsten [EMAIL PROTECTED]
>Gefion Software http://www.gefionsoftware.com
>
>===========================================================================
>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
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
===========================================================================
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