You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Davidson, Misha" <MD...@silverstream.com> on 2000/07/05 17:02:37 UTC

Bug in Struts examples

Hi,

I have noticed a problem with one of the examples that come with Struts.
It relies on a specific (spec non-compliant) behavior in tomcat/jakarta.
I'd like to fix it, but since I am pretty new to this group, I would 
appreciate
any advice as to the best way of correcting the problem.
	
One of the example pages that come with Struts (subscription.jsp, line 43)
contains a statement
	<jsp:getProperty name="user" property="username"/>
without explicitly defining what bean is referred to as "user". I would like
to add a "useBean" statement to that page. Here's why.

JSP 1.1 spec section 2.12.3 explicitly says that the bean instance used by
"jsp:getProperty" tag "bust be defined [sic] before this point in the page
(usually via a useBean action)." Similarly, the definition for 
"jsp:setProperty"
(section 2.13.2) says "The defining element (in JSP 1.1 only a <jsp:useBean>)
must appear before the <jsp:setProperty> element in the same file.

subscription.jsp does not declare the bean "user" in any way.
This works fine with jakarta/tomcat because the Java code generated by
Jasper's JSP compiler does not rely on the bean being declared on the
page (it simply uses PageContext.findAttribute()). However, this behavior is
not very precise (what if I want a "user" bean from a different scope?), it
violates the spec (see above) and it will not compile in other spec-compliant
containers.

So what can I do here? Fix the Struts example? Change code generation in 
Jasper?
Any advice will be greatly appreciated.

-Misha Davidson
misha@silverstream.com

Re: Bug in Struts examples

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Misha,

See embedded notes below.


"Davidson, Misha" wrote:

> Hi,
>
> I have noticed a problem with one of the examples that come with Struts.
> It relies on a specific (spec non-compliant) behavior in tomcat/jakarta.
> I'd like to fix it, but since I am pretty new to this group, I would
> appreciate
> any advice as to the best way of correcting the problem.
>

Suggested changes to Struts can be proposed on the STRUTS-DEV mailing list, so
you're in the right place for that.

>
> One of the example pages that come with Struts (subscription.jsp, line 43)
> contains a statement
>         <jsp:getProperty name="user" property="username"/>
> without explicitly defining what bean is referred to as "user". I would like
> to add a "useBean" statement to that page. Here's why.
>
> JSP 1.1 spec section 2.12.3 explicitly says that the bean instance used by
> "jsp:getProperty" tag "bust be defined [sic] before this point in the page
> (usually via a useBean action)." Similarly, the definition for
> "jsp:setProperty"
> (section 2.13.2) says "The defining element (in JSP 1.1 only a <jsp:useBean>)
> must appear before the <jsp:setProperty> element in the same file.
>

In the short term, I will change the Struts example to use a Struts-specific
version of getProperty which explicitly allows this usage (because it uses
pageContext.findAttribute() to look up the name.

>
> subscription.jsp does not declare the bean "user" in any way.
> This works fine with jakarta/tomcat because the Java code generated by
> Jasper's JSP compiler does not rely on the bean being declared on the
> page (it simply uses PageContext.findAttribute()). However, this behavior is
> not very precise (what if I want a "user" bean from a different scope?), it
> violates the spec (see above) and it will not compile in other spec-compliant
> containers.
>
> So what can I do here? Fix the Struts example? Change code generation in
> Jasper?
> Any advice will be greatly appreciated.
>

I believe that you will see clarifications in JSP 1.2 that make the current
Struts example legal and well defined, but that is then and this is now -- for
now, Struts should be strictly 1.1-compliant.  (there's some other issues in
question, such as "is it legal to reference the bodyContent instance variable in
doEndTag").

>
> -Misha Davidson
> misha@silverstream.com

Craig McClanahan



Re: Bug in Struts examples

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Misha,

See embedded notes below.


"Davidson, Misha" wrote:

> Hi,
>
> I have noticed a problem with one of the examples that come with Struts.
> It relies on a specific (spec non-compliant) behavior in tomcat/jakarta.
> I'd like to fix it, but since I am pretty new to this group, I would
> appreciate
> any advice as to the best way of correcting the problem.
>

Suggested changes to Struts can be proposed on the STRUTS-DEV mailing list, so
you're in the right place for that.

>
> One of the example pages that come with Struts (subscription.jsp, line 43)
> contains a statement
>         <jsp:getProperty name="user" property="username"/>
> without explicitly defining what bean is referred to as "user". I would like
> to add a "useBean" statement to that page. Here's why.
>
> JSP 1.1 spec section 2.12.3 explicitly says that the bean instance used by
> "jsp:getProperty" tag "bust be defined [sic] before this point in the page
> (usually via a useBean action)." Similarly, the definition for
> "jsp:setProperty"
> (section 2.13.2) says "The defining element (in JSP 1.1 only a <jsp:useBean>)
> must appear before the <jsp:setProperty> element in the same file.
>

In the short term, I will change the Struts example to use a Struts-specific
version of getProperty which explicitly allows this usage (because it uses
pageContext.findAttribute() to look up the name.

>
> subscription.jsp does not declare the bean "user" in any way.
> This works fine with jakarta/tomcat because the Java code generated by
> Jasper's JSP compiler does not rely on the bean being declared on the
> page (it simply uses PageContext.findAttribute()). However, this behavior is
> not very precise (what if I want a "user" bean from a different scope?), it
> violates the spec (see above) and it will not compile in other spec-compliant
> containers.
>
> So what can I do here? Fix the Struts example? Change code generation in
> Jasper?
> Any advice will be greatly appreciated.
>

I believe that you will see clarifications in JSP 1.2 that make the current
Struts example legal and well defined, but that is then and this is now -- for
now, Struts should be strictly 1.1-compliant.  (there's some other issues in
question, such as "is it legal to reference the bodyContent instance variable in
doEndTag").

>
> -Misha Davidson
> misha@silverstream.com

Craig McClanahan