tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damian Fauth <dfa...@users.sourceforge.net>
Subject <jsp:useBean> weirdness in custom tags
Date Thu, 15 Jun 2000 16:10:58 GMT
Hi,

I have been developing a custom taglib recently, using Tomcat 3.2dev as
my development environment, when I noticed what seems to be a bug.

I have several tags that extend BodyTagSupport and use <jsp:useBean>
tags within them as follows:
    <form:radio name="country" values="<%= Country.getCountries() %>">
      <jsp:useBean id="country" class="java.lang.String" />
      <b><i><%= country %></i></b><br>
    </form:radio>

This all works fine, until I try to repeat the use of the <jsp:useBean>
tag for the same property elsewhere in the same page: this results in a
"document contains no data" error back from tomcat and the generated
java file that results from the parsed jsp is zero bytes in length. I
tried it in tomcat 3.1 and I get a slight variation: a "missing
resource: java.util.PropertyResourceBundle" error is thrown because the
checkSyntax method of org.apache.jasper.compiler.BeanGenerator can't
find the appropriate error message for the key
"jsp.error.usebean.duplicate". This suggests jasper has been coded to
assume only one <jsp:useBean> tag per property per page, at least in
3.1.

Now, I am unsure what the correct behaviour should be because in a
'normal' jsp there should be no need for multiple <jsp:useBean> tags
with the same property, but within the body of a custom tag, the
'useBean' variable declaration is scoped to within the try/catch block
surrounding the tag, consequently I suspect it should be allowable, and
that Tomcat has a bug. I had a quick look at the 1.1 JSP spec, and could
see no mention of any limitations on the use of <jsp:useBean>

The only way I could think of to do this is the ugly:

    <form:radio name="country" values="<%= Country.getCountries() %>">
      <% country = (java.lang.String)
                  
pageContext.getAttribute("country",PageContext.PAGE_SCOPE); %>
      <b><i><%= country %></i></b><br>
    </form:radio>

What is the reason multiple <jsp:useBean> tags are forbidden fro the
same property? Is this a bug? or am I missing something obvious?

TIA

Damian

Mime
View raw message