________________________________ From: Peter Köhler <peter.koeh...@dw.com> Sent: 15 January 2020 14:49 To: Tomcat Users List <users@tomcat.apache.org> Subject: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox
Von: Léa Massiot <lmhe...@orange.fr> An: users@tomcat.apache.org Datum: 15.01.2020 15:40 Betreff: Tomcat9, JSP, CSS and JS not loading in Firefox Hello, My question is about loading a JSP page in Firefox (or Google Chrome) and not having the CSS loaded and the JS operational. I am using Tomcat v9.0 and Eclipse Java EE IDE v.2019-12 (4.14.0). When I'm developing using Eclipse IDE, I usually: - select a JSP in the "WebContent" directory in the Eclipse workspace, - right-click, - select "Debug/Run As -> Debug/Run on Server" and the Webapp starts debugging/running. With the URL "http ://localhost/<webapp_name>/<page>.jsp", the page gets displayed correctly in the Web browser that Eclipse "embeds" (maybe I.E., I don't know). In Internet Explorer, the page is displayed correctly too. Now, if I copy this same URL "http ://localhost/<webapp_name>/<page>.jsp" in Firefox or Google Chrome, it's like the CSS is not applied to the page, and the Javascript code doesn't run when it should. Note that I didn't use to have that problem before I upgraded Eclipse and Tomcat (I used Tomcat v.8 before). Below is the beginning of the JSP page: ---------------------------------------------------------- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http ://java.sun.com/jsp/jstl/core"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http ://www.w3.org/TR/html4/loose.dtd"> <html lang="${initParam['S_IF_MSG_HTML_LANG']}"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="images/imw.ico?v=2" type="image/x-icon" /> <link rel="stylesheet" type="text/css" href="css/fo.css" /> <title> ${initParam['S_IF_MSG_TITLE_WELCOME']} </title> <meta name="description" content="${initParam['S_META_DESCR_WELCOME_PAGE']}" /> </head> ---------------------------------------------------------- Also in Firefox, I pressed Ctrl + Shift + k and saw the error message: ---------------------------------------------------------- The stylesheet http ://localhost/fr/css/fo.css was not loaded because its MIME type, “text/html”, is not “text/css”. ---------------------------------------------------------- and the warning: ---------------------------------------------------------- The script from “http ://localhost/fr/js/fo.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type. ---------------------------------------------------------- Can you help me solve that problem? Best regards. -- Léa P.S. I added a space after each occurrence of the pattern "http" in this message. -- Sent from: http://tomcat.10.x6.nabble.com/Tomcat-User-f1968778.html --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org Dear Lea, maybe https://stackoverflow.com/questions/48248832/stylesheet-not-loaded-because-of-mime-type helps. Regards Peter Hi Lea, I experienced this problem not so long ago when we upgraded our Tomcat to a later version of 9. Basically we had a filter applied to requests which was supposed to set the encoding of the response to be UTF-8. However, it was also setting the content type to text/html. Previous to the Tomcat upgrade it wasn't an issue. I found that in one of the Tomcat updates (can't remember which one) the logic of the default servlet was altered such that if the content type has already been set in the response it can't be set again further down stream. So my resolution was to remove the line that set the content type in our filter. Something to check anyway as it took me some time to figure out what was happening. Niall