facebook

duplicate var name in different scriplets is a bug [Closed]

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #224310 Reply

    (I am using 3.8.4 on eclipse 3.0.1)
    In the following fragment, the second “String a” is incorrectly flagged as a duplicate variable:
    <body>
    This is my JSP page. <br>
    <%
    String a = “hello”;
    %>
    <%
    String a = “goodbye”;
    %>
    </body>

    Is this a known issue and is it going to (please) get fixed soon?

    #224322 Reply

    Riyad Kalla
    Member

    zero,
    This is not a valid page. If you are interested why, dump this page in Tomcat and try and run it, when it fails, go take a look at the generated Java file, you should see some relatively disgusting code, but buried within that code you will see something like:

    
    String a = "hello";
    // messy generated code for about 4 lines
    String b = "goodbye";
    

    Anything within a scriplet <%%>, is directly inlined into the JSP page, considering that, it is a lot like writing a Java method in a normal Java class like this:

    
    public String getName()
    {
      String name = "Bob";
      String name = "Betty";
      return name;
    }
    
    #224325 Reply

    You are right. I mistakenly tried to simplify my original problem too much. Tthe original problem is with a fragment that looks like:
    <body>….
    <blox:container id=”blox1″ width=”200″ height=”100″ visible=”true”>
    <%
    BloxModel model = blox1.getBloxModel();
    model.setLayout( new VerticalLayout() );
    model.setStyle( new Style( “border:1;” ) );

    RadioButton radioButton1 = new RadioButton(null, “button 1”, “group”);
    radioButton1.setChecked(true);

    %>
    </blox:container>
    disabled = true:
    <blox:container id=”blox2″ width=”200″ height=”100″ visible=”true” >
    <%
    BloxModel model2 = blox2.getBloxModel();
    model2.setLayout( new VerticalLayout() );
    model2.setStyle( new Style( “border:1;” ) );

    RadioButton radioButton1 = new RadioButton(null, “button 1”, “group1”);
    radioButton1.setChecked(true);

    %>
    </blox:container>

    </body>

    It tells me that the second radioButton1 is a duplicate….

    When I simplify this *not so much* it becomes:
    <body>
    This is my JSP page. xxx<br>
    <blox:container>
    <%
    String a = “hello”;
    %>
    </blox:container>

    <blox:container>
    <%
    String a = “goodbye”;

    %>
    </blox:container>
    </body>

    and this works with no error (!)

    So I guess the *real* problem is that when there is complicated scripting nested in tags sometimes you get a bogus duplicate variable error. Or maybe its something related to the <blox:…> tags (?)

    I have tried wrapping the second set of radioButton code in curly braces {} to force it to recognize a new scope but this has no effect.

    Any additional diagnostic suggestions?

    #224327 Reply

    Riyad Kalla
    Member

    and this works with no error (!)

    Are you absolutely sure that THIS page you posted works? The reason I ask is because MyEclipse uses the Jasper2 JSP compiler from Tomcat to validate it’s pages, so if this doesn’t even compile in MyEclipse, but actually RUNs in Tomcat, I will be officially confused-as-hell.

    #224328 Reply

    Yes, this page works — it runs in tomcat with no problem. I have also checked the page in intellij 4.5 and this page is OK as far as it is concerned.

    #224330 Reply

    Riyad Kalla
    Member

    This is certainly strange… is there anyway you would be able to create a small sample web project that contained this identical code and email it to support@genuitec.com ATTN Riyad so I can test it and file a bug report with the issue in it?

    #224336 Reply

    I wish I could do this for you but the tags come from a real honest to god product that we (IBM) sell. And my boss tells me that sending that jar to you would get me fired. Therefore “no” is the answer.
    Seriously tho, I don’t think that our tags are the issue — these tags are out in the wild and have been for 2+ years. And like I noted above the JetBrains product handles the same case w/ no problem (as does Rational App Developer). So I imagine someone less IP-constrained will hit this sort of problem or you will see it reproduced in some other way.

    #224346 Reply

    Riyad Kalla
    Member

    Seriously tho, I don’t think that our tags are the issue

    I don’t either, I agree with your assessment that is why I wanted a sample project so we could file the bug against an explicit use case.

    I have a feeling this bug will get fixed as a side effect of bigger fixes going into 3.9 and 4.0 however… I will try and keep an ear to the ground relating to these types of changes in the code and will post back here if I hear anything. Sorry for the inconvenience and open-endedness of this.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: duplicate var name in different scriplets is a bug [Closed]

You must be logged in to post in the forum log in