You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/09/30 11:52:20 UTC

DO NOT REPLY [Bug 13132] New: - missing declaration of variable

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=13132>.
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=13132

missing declaration of variable

           Summary: missing declaration of variable
           Product: Tomcat 4
           Version: 4.1.10
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Jasper
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: wosc@wosc.de


Consider the following JSP-code:

<% if (condition) { %>
<i18n:message key="some.key" 
id="myID"/>
<% } else { %>
<i18n:message key="some.other.key" id="myID"/>
<% } 
%>

This used to work fine in 4.1.8, but stopped working in 4.1.10.
In 4.1.8 this code would be 
compiled to this:
public void _jspService(HttpServletRequest request, 
HttpServletResponse response) {

[snip some declarations]

java.lang.String myID = 
null;

 if (request.getParameter("test") == null) {
      /* ----  i18n:message ---- */
      {
        [snip some 
custom-tag stuff]
        if (_jspx_th_i18n_message_0.doEndTag() == 
javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
          return;
        myID = (java.lang.String) 
pageContext.findAttribute("myID");
 } else { 
       [snip pretty much the same code again]
 
}

but as of 4.1.10, the declaration of the variable myID was put near the custom-tag call, so the 
compiled code looks like this:
public void _jspService(HttpServletRequest request, 
HttpServletResponse response) {
  [snip declarations]

try {
 if 
(request.getParameter("test") == null) {
      /* ----  i18n:message ---- */
      [snip custom-tag stuff]
      if 
(_jspx_th_i18n_message_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
        
return;
!!>>>   java.lang.String myID = null;     <<<!!
      myID = (java.lang.String) 
pageContext.findAttribute("myID");
} else {
      /* ----  i18n:message ---- */
      [snip custom-tag 
stuff]
      if (_jspx_th_i18n_message_1.doEndTag() == 
javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
        return;
!!>>> no declaration of myID here     
<<<!!
      myID = (java.lang.String) pageContext.findAttribute("myID");
}

and so Jasper 
correctly complains "cannot resolve symbol myID" in the else-clause, because myID is only 
declared once - in the if-clause. (!!)

I assume the fault is on the tomcat-compiler, but it might 
of course well be that the <i18n:message>-tag just relied on the behaviour of tomcat and that the 
handling of that kind of variables isn't even standardized.

PS: If the snippets I put in here 
are not enough context, please email me (wosc@wosc.de) so I can provide more information.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>