facebook

Duplicate local variable "session" error [Closed]

  1. MyEclipse Archived
  2.  > 
  3. Bugs
Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #214756 Reply

    iimuhin
    Member

    Hi All,

    i have installed the last myeclipse version (myeclipse_030801.zip, downloaded yestoday) and the last eclipse3.0 version (eclipse-SDK-3.0-win32.zip, downloaded yestoday). And i habe a problem with it.

    my .jsp:

    <%@ page session=”false” contentType=”text/html; charset=UTF-8″
    %><%
    HttpSession session = request.getSession(true);
    %>

    when i save the file, i see on the right small red bar saing “Duplicate local variable session”. But I don’t see it on the left and I don’t see it in “Problems”.

    If I delete “HttpSession” (no declaration), no errors appear, but Tomcat replies with an error (variable session is not declared).

    WHY???
    I can’t work, all my jsp-s have this structure.

    #214787 Reply

    Riyad Kalla
    Member

    JSP pages come with a set of predefined variables per the spec, they are here: http://www.andreas-rozek.de/JavaServerPages/JSP_02.htm

    #214859 Reply

    iimuhin
    Member

    If you set session=”false” in the header tag, the jsp-compiler should not include own session variable declaration. And so it was always. All earlier versions of myeclipse did it and Tomcat still do it.

    And why I don’t see this error in “Problems”?

    Thanks

    #214874 Reply

    Riyad Kalla
    Member

    If you set session=”false” in the header tag, the jsp-compiler should not include own session variable declaration. And so it was always.

    Interesting, let me look into this.

    And why I don’t see this error in “Problems”?

    Check your problem view filter settings: the litle “down” arrow in the top right corner of the “Problems” view, click it and select “Filters…”, then click “Select All” and “OK”

    #214877 Reply

    Riyad Kalla
    Member

    Ok I checked into the session=false problem and cannot reproduce this locally. I created the following page:

    
    <%@ page language="java" import="java.util.*" %>
    <%
     HttpSession session = request.getSession(true); 
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>My JSP 'MyJsp.jsp' starting page</title>
      </head>
      <body>
        This is my JSP page. <br>
      </body>
    </html>
    

    And as expected got an error on the line with HttpSession, then I changed the paeg to this (note the @page directive change):

    
    <%@ page session="false" language="java" import="java.util.*" %>
    <%
     HttpSession session = request.getSession(true); 
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>My JSP 'MyJsp.jsp' starting page</title>
      </head>
      <body>
        This is my JSP page. <br>
      </body>
    </html>
    

    And the error went away. Can you try this EXACT same test locally and see if it works? Also what are the Build IDs of the Eclipse install (Help > About) and MyEclipse install (Window > Prefs > MyEclipse) that you are using?

    We use the Jasper2 compiler from Tomcat to compiler our JSP pages, so whatever errors that are showing are likely legitamate errors, unless the error marker is a red herring for something else?

    #214933 Reply

    iimuhin
    Member

    Hello,

    Eclipse build date: Fri, 25 Jun 2004 — 12:08 (-0400) (Version 3.0)
    MyEclipse build date: 8/22/2004 (Version 3.8.1)
    Java DK: 1.5RC1

    Another programmer in the firm has the same error on his computer. But he works with Struts ans JDK1.4, so he can live with it. But I don’t. I still have to use the old version of myeclipse.

    We use the Jasper2 compiler from Tomcat to compiler our JSP pages

    What do you mean? Only you use it, or it is in myeclipse?

    Thanks,
    Igor

    #214935 Reply

    iimuhin
    Member

    I repeat the installation and tested the case again. The same story.

    I describe what did I do:
    1) unpacked eclipse archive
    2) unpacked myeclipse archive
    3) started eclipse
    4) Help -> Software Update -> Manage Configuration -> New -> Extension Location…
    5) restarted eclipse
    6) created new J2EE Web Project
    7) created new JSP Page
    ..see the first screenshot.

    To make you sure, i made screenshots.

    The error (On the right is the error, but not in “Problems” (no filters)):

    Eclipse version:

    MyEclipse version:

    Thanks,
    Igor.

    #214946 Reply

    Riyad Kalla
    Member

    Igor,
    Jasper2 is the JSP compiler that is part of MyEclipse now, so everyone uses it.

    Also, the errors on the RIGHT side of the screen are reconciler errors (real-time if you will) and currently are not entirely accurate. They will never be shown in the problems view (the Java Editor doesn’t do this either), only left-hand margin errors are shown in the problems view.

    So this error is actually harmless, BUT I do not see this faulty reconciler issues on my install which is strange. Are you running all the quickfixes? (can you tell me the build id from Window > Prefs > MyEclipse screen?)

    #214957 Reply

    iimuhin
    Member

    Hello support-rkalla,

    if I add another error, it will be also incorrecly shown (nothing on the left, nothing in Problems):

    myeclipse version:

    Thanks,
    Igor

    #214971 Reply

    Riyad Kalla
    Member

    Are you using our JSP editor? When you right click and “Open With” on your JSP files, is the default editor “MyEclipse JSP Editor”?

    I am running out of ideas here, note how mine looks with identical content:

    And the build info:

    #215067 Reply

    iimuhin
    Member

    Hi,

    The default jsp-editor is MyEclipse JSP Editor on my computer.

    I have looked in .log file in the workspace directry. And there are strange exception about jsp compiler!!!!! I put the file on the server: http://prelive.audi-lis.com/Temp/.log

    Please check this screenshot. Is all builders in there (My collegue has more entries, he has also NOP JSP Builder).

    Thanks,
    Igor[/url]

    #215072 Reply

    Riyad Kalla
    Member

    Ahhhhh,
    Igor do you have javac.exe in your path? You need to for the JSP compiler to work (we will fix this hidden requirement in the next release).

    Make sure to add your JDK’s bin directory to your PATH environment variable and then restart MyEclipse.

    #215078 Reply

    iimuhin
    Member

    Thanks you very much, support-rkalla. Now it runs correctly.

    I would like you to fix this problem as soon as possilble. Because some my projects should be compiled with Java 1.4 and some with Java 5.0. It was possible with old version of the eclipse but not now.

    Igor.

    #215079 Reply

    Riyad Kalla
    Member

    Igor:

    I would like you to fix this problem as soon as possilble. Because some my projects should be compiled with Java 1.4 and some with Java 5.0. It was possible with old version of the eclipse but not now.

    I’m not sure I understand what you are referring to… when you say “Some projects need to be compiled with 1.4 and some with 5.0” do you mean the Java classes or the JSP pages? The java class compilation is handled by the JDT’s incremental compiler that is part of Eclipse, not by javac.exe, javac.exe is ONLY used to validate JSP files.

    Unless you meant JSP files?

    #215088 Reply

    iimuhin
    Member

    I mean that my JSP pages in a project can contain Java 1.4 syntax. And in another project Java 5.0 syntax (generic types, new loops).

    I can’t change the PATH environment variable each time I want to validate JSPs in another project.

Viewing 15 posts - 1 through 15 (of 16 total)
Reply To: Duplicate local variable "session" error [Closed]

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