Would we be happier if the useBean tag could take arguments?
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Matt Krevs
Sent: 06 December 1999 22:11
To: [EMAIL PROTECTED]
Subject: Re: What's the use of [<jsp:useBean> tag]?
Maybe one of the things we are all missing is that most of us on this forum
(I assume) are programmers and are used to seeing java code embedded in
things. Consider for a second that one major reason JSP was developed was to
separate presentation from business logic. One advantage of the usebean tag
provides a HTMLish tag that non-programmers can more easily use in their
HTML.
Granted it may be fairly simple for Java programmers to simply use
<% MyBean mybean = new MyBean() ;
mybean.setSomeVar( "somevalue" ) ; %>
instead of
<jsp:useBean...>?
but the useBean tag is much easier to use for non-programmers.
I guess another possibly more important reason to use the useBean tag is
that it hides the specific implementation of 'bean' scoping from the
programmer. What happens if suddenly, behind the scenes, the way that
application scope beans are stored/retrieved is changed in a future JSP
release or implementation? If you have hardcoded java code in your JSP pages
(eg getServletContext().setAttribute( key, value ) ) then chances are you
have a very large search/replace task on your hands. If you instead used the
'usebean' tag then you dont have anything to worry about.
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Kayser William
Sent: Tuesday, December 07, 1999 6:03 AM
To: [EMAIL PROTECTED]
Subject: Re: What's the use of [<jsp:useBean> tag]?
Yes, I've always wondered this myself. Surely we're all missing something
very
obvious...
Bill
Phil <[EMAIL PROTECTED]> on 12/06/99 09:58:42 AM
Please respond to Phil <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Bill Kayser/Worldstreet)
Subject: Re: What's the use of [<jsp:useBean> tag]?
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
===========================================================================
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