Skip to content Skip to sidebar Skip to footer

.js And .css Files Are Loading As Text/html In My Jsp Page.

When I load my jsp page, the attached css and js files are rendered as text/html format. I noticed it from chrome browser where I could see this error message 'Resource interprete

Solution 1:

I finally found the reason for this issue. I just fixed web.xml by changing the default url mapping

eg. from the default value as below

<servlet-mapping><servlet-name>My Application</servlet-name><url-pattern>/*</url-pattern></servlet-mapping>

to

<servlet-mapping><servlet-name>My Application</servlet-name><url-pattern>/home/*</url-pattern></servlet-mapping>

After changing this I still got an error which I fixed by adding

<servlet-mapping><servlet-name>My Application</servlet-name><url-pattern>/VAADIN/*</url-pattern></servlet-mapping>

which is covered in the Book of Vaadin, section 4.8 https://vaadin.com/book/-/page/application.environment.html

Solution 2:

In my case, I have a filter in my web.xml that filters everything. (It redirects to a certain page based on the IP address.)

<filter-mapping><filter-name>RedirectFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping>

With this filter mapping, all requests (including images, stylesheets, scripts, etc.) go through the filter. You can fix it by either removing the filter-mapping from your web.xml or checking the logic in the filter-class to allow or ignore the resources.

Post a Comment for ".js And .css Files Are Loading As Text/html In My Jsp Page."