tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 21967] New: - Custom tags defining scripting variables but not always
Date Tue, 29 Jul 2003 14:28:07 GMT
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=21967>.
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=21967

Custom tags defining scripting variables but not always

           Summary: Custom tags defining scripting variables but not always
           Product: Tomcat 4
           Version: 4.1.24
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Jasper 2
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: tdeverdiere@scort.com


When i have a tag defining scripting variables in my Jsp. If i choose to declare
with TagExtraInfo class this variable always this way :

public class FunctionTEI extends TagExtraInfo {

    public VariableInfo[] getVariableInfo(TagData data) {
        if (data.getId() != null)
            return new VariableInfo[] {
                new VariableInfo(
                    data.getId(),
                    "String",
                    true, // ALWAYS TRUE !! SO IT SHOULD ALWAYS BE DECLARED ?!
                    VariableInfo.AT_BEGIN
                )
            };
        
        return null;
    }
}
Suppose we associate it with the function tag :
Then i suppose that two calls of the tag will declare twice my variables !
But this is not true.
ex1:
-----------
<pref:mytag id="var" value="ok" />
<pref:mytag id="var" value="nok" />
<%= var %>
------------
This makes no compilation error and returns this result :
nok


ex2:
-------------------
<% int i = 0;
if (i = 0) { %>
<pref:mytag id="var" value="ok" />
<%= var %>
<% } else { %>
<pref:mytag id="var" value="nok" />
<%= var %> This generate the error.
<% } %>
---------------------
This makes a compilation error !
cannot resolve symbol var
This is due to the fact that var is not being declared in the else condition
whereas it is in the first condition.
For me example 1 should throws an error because 'var' has been already declared,
whereas example 2 should work because i declared in separate scope of the code
my 'var'.

However the behaviour is not well defined in JSP 1.2 but
<jsp:useBean id="var" class="String" />
<jsp:useBean id="var" class="String" />
Generates an error !) so i think custom tags defining scripting varibales should
be consistent with this behaviour.

The error is during translation not compilation.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message