tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <>
Subject Re: <jsp:useBean> weirdness in custom tags
Date Thu, 15 Jun 2000 18:13:53 GMT
Damian Fauth wrote:
> 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?

It may be a bug that Tomcat doesn't report what the problem is in a 
sensible way, but it seems like what you want to accomplish should be
done without using <jsp:useBean> in the first place.

View raw message