John Strickler
John Strickler

Reputation: 25421

Why is Eclipse/JSP parsing my JavaScript?

I have a JSP page which doesn't actually have any server tags in it so its basically an HTML page. But, my work is in love with JSP so I set it as a .jsp file. Anyhow, Tomcat is under the belief that my JavaScript is in fact Java code and tries to parse it. I get a nice big error on the screen saying its not a real function, etc. Could anyone tell me why its doing this? Code below...

...
<script>

    $(function() {

        $.dragAndDrop({
            dom: {
                fileList: '#fileList tbody',
                contextMenu: '#fileContextMenu',
                dropzone: '#dropzone'
            },
            templates: {
                file: '<tr><td>${fileName}</td><td>${$.dragAndDrop.getDate()}</td><td>${$.dragAndDrop.parseSize(size)}</td></tr>'
            }
        });

    });

</script>
...

The error:

org.apache.jasper.JasperException: /index.jsp(22,42) The function getDate must be used with a prefix when a default namespace is not specified
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)

Upvotes: 0

Views: 787

Answers (2)

700 Software
700 Software

Reputation: 87883

It is likely the ${ notation

Try replacing this code ${$

with something like this $' + '{$

or $<%='{'%>$

I don't know if there is a proper way to escape that,, but what I just gave you should work.

See Google for more information. The top result looks good but I could not find how to do a proper escape: http://www.google.com/search?q=jsp+dollar+sign

Upvotes: 2

Felix Kling
Felix Kling

Reputation: 817198

${} marks expressions for evaluating via JSP. As you say you don't use any JSP, you can disable the expressions language by adding

<%@ page isELIgnored="true" %>

to your page.

Upvotes: 3

Related Questions