DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26845>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26845

<bean:define> within a conditional scriplet produces Unable to compile class for JSP 
Error

           Summary: <bean:define> within a conditional scriplet produces
                    Unable to compile class for JSP Error
           Product: Struts
           Version: 1.1 Final
          Platform: PC
        OS/Version: Windows NT/2K
            Status: UNCONFIRMED
          Severity: Minor
          Priority: Other
         Component: Custom Tags
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The development team I work with (most members are relatively new to JSP and
STRUTS) produced a JSP which contained a structure like the following:

  <% String PropertyName=request.getParameter("popup"); %>
  <% String popupType=request.getParameter("popupType"); %>
  <bean:define id="collectionCollection" name="<%=IWebConstants.MODEL_HANDLER%>"
   property="collectionCollection" scope="session" toScope="page"/>

  <%if (popupType.equals("multi")) { %>
    <bean:define id="collection" name="collectionCollection"  
      property="<%=PropertyName%>" scope="page" toScope="page"/>
    <html:select property="pageProperty" name="pageForm" multiple="true" 
      size="10" onchange="FillBuffer()">
      <html:options collection="collection" property="value" 
        labelProperty="key"/>
    </html:select>
  <%} else {%>
      <bean:define id="collection" name="collectionCollection" 
        property="<%=PropertyName%>" scope="page" toScope="page"/>
      <html:select property="pageProperty" name="pageForm" size="10" 
        onchange="FillBuffer()" onclick="SubmitToForm()">
        <html:options collection="collection" property="value" 
          labelProperty="key"/>
      </html:select>
  <%}%>

The above is not very efficient, but was validated as syntactically correct
within the IDE.  The JSP containing the above, when deployed in a WARfile, is
compiled correctly in Tomcat 4.0.x and BEA Weblogic 7.0SP2.   However, when
deployed to Tomcat 4.1.27, 4.1.29 and 5.0.18 the JSP fails with the error
(paraphrased):
Unable to compile class for JSP.  
test.jsp_jsp.java:xx: cannot resolve symbol
symbol: variable collection
etc.

Examing the test.jsp_jsp.java (generated by Tomcat in the work directory) showed
the if..else block constructed improperly.  The if block contains a variable
declaration: java.lang.Object collection = null (from the bean:define) which is
used within it.  The else block contains code that just tries to reference a
variable collection but does not declare it (which is where the cannot resolve
symbol arises).

The test was performed on Windows 2000 Professional, JDK 1.4.2_01 and 1.3.1_09
using Struts 1.1 Final (using Tomcat 4.0,4.1.27,4.1.29,5.0.18 and BEA Weblogic
7.0SP2).  It was also independently executed on JDk 1.4.2_01 on another Windows
2000 device using Tomcat 4.1.27.

We are hoping to see if we can reproduce the error with a stripped-down version
of the JSP (since it contains more than the snippet where the error appears to
arise).  It has been confirmed if the <bean:define>(s) within the if..else
scriplet block are replaced by a single instance outside of the scriplet the
page compiles correctly on all of the above containers.  We are unsure if this
is a STRUTS tag issue or Tomcat issue at this point (or something else).

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to