As I understood it, Heiko was asking why use JSP tag <jsp:useBean...> when
you can do the same by creating an instance of the java "bean" object...
(the original e-mail subject line may have sent the conversation in a
different direction).
It seems the <jsp:useBean> tag is redundant. According to the specs, a bean
is just a java component, requiring "serialization support" and "get/set
accessors." According to the-wally-project tutorials, "JSP is an html
friendly servlet." Other than limits imposed by design preference, what ever
you can do in a servlet you can do in JSP, including:
<% MyBean mybean = new MyBean() ;
mybean.setSomeVar( "somevalue" ) ; %>
So, why use JSP tag <jsp:useBean...>?
Phil
-----Original Message-----
From: Cory L Hubert <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, December 06, 1999 7:25 AM
Subject: Re: What's the use of beans?
> What you suggested would be fine if you want to bang out a whole
project in
>a perl/hackish fashion. But if you want to be able to reuse code, in your
>project and in others the best way to do it is by encapsulating code in
>beans.
>
>-----Original Message-----
>From: A mailing list about Java Server Pages specification and reference
>[mailto:[EMAIL PROTECTED]]On Behalf Of Heiko Gottschling
>Sent: Sunday, December 05, 1999 7:10 PM
>To: [EMAIL PROTECTED]
>Subject: What's the use of beans?
>
>
>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.
>
>For example,
>
><jsp:useBean id="myBean" class="MyBean" scope="session">
>
>can easily be replaced by
>
><% MyBean myBean = new MyBean();
> session.put("myBean", myBean); %>
>
>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.
>
>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?
>
>thx
>Heiko
>
>===========================================================================
>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
>
===========================================================================
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