facebook

Reports a JSP error but works?

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

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

    Chris Parsons
    Participant

    The variable ‘colours’ shown below reports as a syntax error in the JSP page but it still compiles and works!

    
    <bean:define id="colours">
      <bean:message key="colourlist" />
    </bean:define>
    
    <sdlogic:iterate name="serviceListForm" 
    property="services" id="service"
    colourId="c"
    colours="<%= colours %>">                  <<<<<<< 'colours' shows as an error?
    <tr bgcolor="<bean:write name="c" />">
    ...
    </sdlogic:iterate>
    

    Any ideas?

    Chris

    <SNIP, please use MyEclipse > About MyEclipse > Insatllation Summary when posting system info>

    #254853

    Riyad Kalla
    Member

    Chris,
    This is a tricky problem to solve and most likely won’t be solved anytime soon. You know what bean:define does, so you know why the code above works. You also understand why the scriptlet executes correctly at run time (Because the variable exists). The problem is that the JSP syntax parser has no idea what bean:define does. Consider that I could write a custom taglib called “blork” with a method called “florp”, so I would have:

    
    <blork:florp id="colours">
    </blork:florp>
    

    Let’s also say that I copy-paste all the code from Struts bean:define tag and put it in my blork taglib, so it does the identical thing. How can the parser know, from the syntax alone, that blork is creating a page-scoped variable with the name “colours”? It can’t without running the code and analyzing the result.

    Anyway, the reason I say the problem most likely won’t be solved is because using scriplets in JSP pages have always been considered “Bad practice” even though sometimes you need to. Now with the JSP 2.0 spec you can actually set a flag (off by default I think) that disallows scriplets completely in the JSP pages, negating problems like these. So it’s my belief that moving forward the spec will continue to diswade developers from using scriplets so this problem will become even more of an edge case.

    #256302

    Chris Parsons
    Participant

    Yes, I suspected it was something like this – the reason for using this code was to retrieve a value from a properties file (application.properties) to colour stripe the rows in a table via a custom tag library, if you have any alternative suggestions I could try them (I guess hardcoding is an option!)

    Thanks

    Chris

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Reports a JSP error but works?

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