I am trying to include jquery.js and javascript.js files on my page, as proposed in the previous question by passing it through the Servlet class like:
response.getDocument().body().appendChild(new DataNode("<script src=\"" + themeUri
+ "/js/nativeinit.js\" type=\"text/javascript\"></script>",""));
response.getDocument().body().appendChild(new DataNode("<script src=\"" + themeUri
+ "/js/jquery.min.js\" type=\"text/javascript\"></script>",""));
When I see the Console in Browser though I see the messages for both files:
Resource interpreted as Script but transferred with MIME type text/html: "http:8080/uri/js/nativeinit.js". myhost/:47
Resource interpreted as Script but transferred with MIME type text/html: "http:8080/uri/js/jquery.min.js". myhost/:47
And then:
Uncaught SyntaxError: Unexpected token < nativeinit.js:1
Uncaught SyntaxError: Unexpected token < jquery.min.js:1
What is wrong and it cannot read them as script? Why this strange message of unexpected token? What should I change/add?
Update:
I have also added in my web.xml file:
<mime-mapping>
<extension>js</extension>
<mime-type>application/javascript</mime-type>
</mime-mapping>
but problem with the same message remains. I am aware of the fact that @Javascript
annotation is the recommended way in vaadin 7, but I think it should work as well on the common way. I do not set Content Type in Servlet Class. I can use there only the class BootstrapPageRespone
from https://vaadin.com/api/ , which does not provide the methods from ServletResponse
. Otherwise I would have set it also programatically.