Volker Turau wrote:
>
> Hi,
>
> I have implemented some of the components available in Microsofts ASP as
> Java Beans and used these components in JSP. In doing so I found that the
> Bean concept in JSP has severe limits. I would like to hear your opinions
> about my thoughts:

JavaBeans are primarily good as data containers, not as components that
do more than validate the property values. In JSP 1.1 you will be able to
use custom tags (see the Tag Extension section in the JSP 1.1 draft spec)
to do all of the things you list below. You can get the JSP 1.1 spec at
http://java.sun.com/products/jsp/

> 1. Using only the three actions useBean, setProperty and getProperty
> does not allow really interesting beans. Very often I wanted to invoke
> a method having parameters and printing the result. Printing is only
> possible using getProperty which does not accept parameters.  It would
> be usefull, if this action would accept additional parameters, for
> example
>
> <jsp:getProperty name="name" property="pName">
>    <jsp:param name="param1" value="44"/>
> </jsp:getProperty>

A custom tag for this could look like:

  <foo:myTag param1="pName" param2="44" />

It has access to the "out" object so it can add to the response body.

> 2. Beans should have access to implicit objects such as request,
> response etc. Currently you have to use scripts again, for example

A custom tag has access to all implicit objects through the pageContext
object.

> 3. In order to assign the value of a property to a scripting variable,
> you cannot do something like:
>
> <% int i = %> <jsp:getProperty name="name" property="pName"/>

Custom tags can introduce new scripting variables, e.g.

  <foo:myTag id="i" param="pName" />

uses the special "id" attribute which the JSP engine (with help from the
tag implementation) associates with a scripting variable that you can
use after this tag.

--
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

Reply via email to