facebook

Unable to see %> on JSP Expression…

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

    Unnsse Khan
    Member

    Hello,

    I am using Eclipse 3.1 on OS X Tiger, with the MyEclipseIDE plug-in…

    My color settings are set as follows:

    1. Editor’s background is black.

    2. Java code is set to white.

    3. HTML tags are blue.

    4. JSP delimiters are white.

    Wrote a simple JSP file and the closing % for my opening JSP Expression (<%=)
    does not appear on the screen, it looks like this:

    
    <%@ page import = "foo.*" %>
    
    <html>
        <body>
    The page count is:
    <%
        <%= Counter.getCount() %>
    >
    
        </body>
    </html>
    

    Now, when I just toggled / highlighted the code (in order to paste it in here), I did see it there, but
    for some reason or another Eclipse doesn’t recognize the <%= and didn’t even code complete the closing %>.

    The reason I know it doesn’t recognize it is because I get the following errors and warning:

    1. Error:

    line 7: illegal start of type: <%= Counter.getCount()

    2. Error:

    line 11: expected: out.write(“\n%>\n\n </body>\n</html>”);

    3. Warning:

    line 8: Invalid character used in text string ( %> ).

    Am really disappointed by this! This is such a simple piece of code
    and it seems like the MyEclipseIDE plug-in doesn’t recognize JSP expressions ( <%= %> ).

    Has anyone seen / experienced a similar problem?

    Please help!!!

    #253831 Reply

    Riyad Kalla
    Member

    Am really disappointed by this! This is such a simple piece of code
    and it seems like the MyEclipseIDE plug-in doesn’t recognize JSP expressions ( <%= %> ).

    Has anyone seen / experienced a similar problem?

    It doesn’t recognize it because it’s invalid. You cannot embed expressions inside of scriplets, or scriplets inside of scriplets. To understand why, consider that the <%%> delimiters are used by the JSP compiler to denote “inline the following code” then everything, Java code, between <% and %> is directly inlined into your compiled JSP (Servlet class). If you put <%= blah blah %> in there, you end up with Java code that looks like this in the actual class that is trying to be compiled by the app server:

    
    System.out.println("\t\t\t\t<td>");
    <%= Counter.getCount() %>
    System.out.println("\t\t\t\t</td>");
    

    Which as you know is not valid Java. Your code needs to be something like this:

    
    The page count is: <%= Counter.getCount() %>
    

    Remember, everything between <% and %> is straight Java code. I think you are mixing up how to use <%%> and <%=%>. <%%> is usually used to include processing code or code that does stuff, and <%=%> is used to insert text into the output of the page, like a toString() on something.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Unable to see %> on JSP Expression…

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