2016 shows errors in jsp with JSTL & javascript

This topic contains 7 replies, has 3 voices, and was last updated by Profile photo of support-swapna support-swapna 4 months, 2 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #505066 Reply
    Profile photo of greybeard
    greybeard
    Participant

    Typical is:
    var doorHeightMax = <c:out value=”${cabinetDoorPricing.doorsHeightMaxMin.maxValue}”/>;
    gives error: “Unexpected Token”
    AND more is:
    var isUBO = <c:choose><c:when test=”${orderForm.chosenProduct.pricePlan.isUnderBenchOven eq true}”>true</c:when><c:otherwise>false</c:otherwise></c:choose>;
    gives error: “expected end of statement or expression”

    due to these & other errors the whole page is littered with supposed errors. How do I suppress these errors to make it “ignore” (even make them “warning”)
    thanks & regards

    #505101 Reply
    Profile photo of support-swapna
    support-swapna
    Moderator

    greybeard,

    The problems reported are from JavaScript parser. Any html code is transparent to the JavaScript compiler because the output is determined only at server runtime. So all the HTML content is replaced by spaces.Also mixing and matching JSTL and JavaScript is not recommended.

    Providing proper validation for such syntax is virtually impossible unless you run the code, so when we detect it, we can just downgrade syntax errors to warnings.The problems on the code should be reported as warnings and not errors.

    To avoid these validation issues, you should use EL expressions ${..} directly within the JavaScript code .Example : var doorHeightMax = ${cabinetDoorPricing.doorsHeightMaxMin.maxValue};

    Alternatively, I see that if there is atleast one valid EL expression in the <script> section, then all the related problems are shown as warnings, otherwise they are shown as errors.

    Can you please replace one of the variable declarations with EL expression and check if the problems are showing up as warnings? I will file a bug with the dev team to investigate about the problems being shown as errors.

    Sorry for inconvenience caused. Please let us know how it works for you.

    –Swapna
    MyEclipse Support

    #505113 Reply
    Profile photo of greybeard
    greybeard
    Participant

    Thank you for your response. I note that there are more issues when the JSTL/JS mixed in a jsp. Another issue is js comments viz:
    //<%– if okToUse then put the altered drawer to it’s requested height –%>
    if(okToUse == true) {
    …..
    The open brace is marked as an error thus stuffing up all subsequent braces.

    I use the above js/jsp comment form so that the comment is NOT seen at run time.

    These have never been an issue prior to 2016 version

    #505343 Reply
    Profile photo of support-swapna
    support-swapna
    Moderator

    greybeard,

    Apologies for delayed response. The difference between MyEclipse 2016 and previous versions is that we have moved to JSJet in MyEclipse 2016 for JavaScript.

    The error on the JS comment might be a bug in our editor and I have filed it with the dev team for further investigation.

    As suggested in my previous response, can you please clarify whether adding a valid EL expression to the script section changes the error markers into warnings?

    Apologies for inconvenience caused.

    –Swapna
    MyEclipse Support

    #505589 Reply
    Profile photo of support-piotr
    support-piotr
    Moderator

    Greybeard,

    I cannot reproduce your issue with JSP-style comments (attached is a screenshot of a sample I used to reproduce the issue). Could you please provide the actual code before and after to reproduce the issue? A screenshot would also be handy. Thanks!

    Piotr Tomiak

    Attachments:
    You must be logged in to view attached files.
    #505592 Reply
    Profile photo of greybeard
    greybeard
    Participant

    HERE is before & after shots of jsp file (I have added my comments for clarity):

    Also another issue within js functions:
    if(xxxx < min || xxxx > max){ etc causes error marker at the “greater than” operator.
    to get rid of error I used
    if(xxxx < min || xxxx >= max + 1){ etc no error using “greater than or equal to” operator
    “less than” does not cause an error to be shown

    Attachments:
    You must be logged in to view attached files.
    #505596 Reply
    Profile photo of support-piotr
    support-piotr
    Moderator

    Greybeard,

    I’ve reproduced both reported issues with provided examples. Thank you very much for your reports! The first issue was happening, because we were indeed not properly handling JSP comments, the other due to incorrect regexp, which was replacing everything between < and > with spaces. Both fixes will be included in the next MyEclipse release – 2017 CI 1, which is due this or next week. Let me know if you see any other issues!

    Best regards,
    Piotr Tomiak

    #508092 Reply
    Profile photo of support-swapna
    support-swapna
    Moderator

    Greybeard,

    MyEclipse 2017 CI 1 is out and it has the fixes for the issues you reported. Please download the MyEclipse 2017 CI 1 installer from here : https://www.genuitec.com/products/myeclipse/download/

    You can install MyEclipse 2017 CI 1 to a different location alongside your existing MyEclipse 2016 installation and use your current license. Please give it a try and let us know how it works for you.

    –Swapna
    MyEclipse Support

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: 2016 shows errors in jsp with JSTL & javascript