You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Léa Massiot <lm...@orange.fr> on 2020/01/15 14:40:13 UTC
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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by "André Warnier (tomcat/perl)" <aw...@ice-sa.com>.
On 16.01.2020 10:36, Lmhelp1 wrote:
> Hello,
>
> Thank you for your answer.
> Indeed, I have such a filter:
>
> In "web.xml":
> ----------------------------------------------------------------------------------------
<!--
> <filter>
> <filter-name>EncodingFilter</filter-name>
> <filter-class>com.[...].EncodingFilter</filter-class>
> <init-param>
> <param-name>requestEncoding</param-name>
> <param-value>UTF-8</param-value>
> </init-param>
> </filter>
> <filter-mapping>
> <filter-name>EncodingFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
-->
> ----------------------------------------------------------------------------------------
>
[...]
What happens if you disable that filter entirely, in web.xml ?
(comment-out the whole section above, as shown)
Note : ignore any character encoding errors that you may get in the response, for now.
(probably shown as <?>). The point is to verify if it is really that filter which causes
the problem with the CSS files.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Léa,
On 1/16/20 4:36 AM, Lmhelp1 wrote:
> Hello,
>
> Thank you for your answer. Indeed, I have such a filter:
>
> In "web.xml":
> ----------------------------------------------------------------------
- ------------------
>
> <filter> <filter-name>EncodingFilter</filter-name>
> <filter-class>com.[...].EncodingFilter</filter-class> <init-param>
> <param-name>requestEncoding</param-name>
> <param-value>UTF-8</param-value> </init-param> </filter>
> <filter-mapping> <filter-name>EncodingFilter</filter-name>
> <url-pattern>/*</url-pattern> </filter-mapping>
> ----------------------------------------------------------------------
- ------------------
>
>
>
> The "doFilter()" method of the "EncodingFilter" class which
> implements "Filter":
> ----------------------------------------------------------------------
- ------------------
>
> public void doFilter(ServletRequest servletRequest,
> ServletResponse servletResponse, FilterChain filterChain)
> throws IOException, ServletException { // Respect the
> client-specified character encoding // (see HTTP specification
> section 3.4.1) if(servletRequest.getCharacterEncoding() == null) {
> servletRequest.setCharacterEncoding(ms_encoding); }
>
> // Set the default response content type and encoding
> servletResponse.setContentType("text/html; charset=" +
> Finals.S_CHARSET);
> servletResponse.setCharacterEncoding(Finals.S_CHARSET);
>
> filterChain.doFilter(servletRequest, servletResponse); }
Nobody should ever use such a filter: it completely clobbers the
response content type and character set, and does so for *every
resource served by the application*.
> Commenting the line: servletResponse.setContentType("text/html;
> charset=" + Finals.S_CHARSET); doesn't solve the problem.
Did you recompile/reinstall?
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4hJicACgkQHPApP6U8
pFgtwQ//dNP3t7puLUw615yu1sKJFf07cyK3pnJ1BT4t9nMLkMJMNzZwUGkcc/ML
SuSqE9wlB488C6S0RZiIKN9Z4JmFXj1ndF7N374t6ZNcage8YUgSdNwMJ/TdsYLJ
ep42AfscAAcoKJc4sGuPGy/NGwU4VMBRn7N5aVfahodX081gdOaIdJupmHochUwv
qM/LvyJ5KuL6IUp9zOkQHFIWEeCRJeV3NLGa0sKzZD1S9Syx8PAVHaj5Cec2gGX5
lDgztxWqwS7nMeEC7NLLV6PbmnaMWWZvW0dPPpHC+IbHJT3KIlKggY6L6qEt2E1X
XuKeNTuT6attptKAlUY3S7vojzC5iNz3MFjJIzr6B5XoTC9DNlKr/n7haadIekhO
iLOO4faDWInGKhZ4b9w1ZsDBIMxdAyb40igGDmH2QcFaqRK4F0pGVqr7x2jkk9Jm
k7IPqFfzTqW92aJ6bhE4tpCl7msjl8ty5IDuNCqZgMbOgYFvCCUj2WXK10hfiPCj
xsABTL0VIa+FbHMWDlHFjFUVNPqsqn3CvxPY1iAcPWj5u7si2OWFyCXEsIILjUdF
TXTJ73Rd9hSJCt4PpZBqUPzEkLOiMvxj8Z32VzCqN5nHiWNofh0+g5kmu6kP76YH
sOQl+Ak5hdb2zCehcCnFFNCZPEQA9XFqw/wVng+SJ94dmM/rwPU=
=1MqD
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [OT] Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
André,
On 1/23/20 5:18 AM, André Warnier (tomcat/perl) wrote:
> On 22.01.2020 10:26, Lmhelp1 wrote:
>> Hello Chris and all,
>>
>> Sorry for my late answer. Thank you for the link you suggested me
>> to read. Adding the element:
>> <request-character-encoding>UTF-8</request-character-encoding> to
>> "web.xml" solved my problem.
>>
>
> Glad to hear that. From an absolute point of view, this is of
> course again a "patch". But as Chris pointed out before, it is
> unfortunately an unavoidable one, due to the fact that the browsers
> lamentably fail to always indicate the character set and encoding
> that they are using for sending text data to the server.
>
> [RANT:] (Although they know, and although the specifications
> provide them with an easy way to do that. Why that is so is
> anyone's guess, but the economic losses due to that over the years
> must be staggering). (probably close to the cost of allowing spaces
> in directories and files names)
+1
It's mind-boggling that browsers do not provide Content-Type with
encoding. It is 100% safe to include it, and 100% awful when they do
not. The spec says that when the encoding is not included, there is a
default. But the browser will change the default and then not
communicate it to the server. Breathtakingly stupid.
I would also support an HTTP revision that included a
Request-Line-Encoding header to tell the server which encoding the
client had used to send the request-line, since there is no other way
to communicate that. It may require re-interpretation of the
request-line, but at least it would be doable at that point.
- -chris
>> On 17/01/2020 3:17 PM, Christopher Schultz wrote:
>>> Your filter changes the encoding of both the request AND the
>>> response. It's likely that fixing the request-encoding was
>>> necessary, while changing the response-encoding was not.
>>>
>>> The problem is:
>>>
>>> 1. The official RFC-defined default character encoding for HTTP
>>> is ISO-8859-1.
>>>
>>> 2. The browser default appears to be unpredictable, but often
>>> UTF-8.
>>>
>>> 3. The browsers have all agreed not to tell the server what
>>> characted encoding is actually being used.
>>>
>>> It's fun. It's a very simply-solved problem: the browser should
>>> just advertise the character encoding and everything would be
>>> great. Sadly, n o.
>>>
>>> I would encourage you to read this page in its entirety:
>>> https://cwiki.apache.org/confluence/display/TOMCAT/Character+Encodin
g
>>>
>>>
>>>
- - -chris
>>
>>
>> ---------------------------------------------------------------------
>>
>>
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
> ---------------------------------------------------------------------
>
>
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4rAlYACgkQHPApP6U8
pFhfSxAAxzhMaJJynEKKfK8APgx0WOFesiNQH7qoOwzjRw1LA/y3vZMVgoX/K6E/
avj69YD/YQKah/CkhBX/6lOSlGwJRYrpU/dpQOaAjoHJHyeR8ZR3RASmZ5rehsKz
Ah1YUysqlsDz7YXtzwKpg1JdW6g+Lkocb0oeniEMVpMFzedtSp5h2/+DbGvIhvzf
KDtkiaP+dV2Iap2Upfeg9q5gXina43+CPsscmSXP7CcGZ8XRx2R8B2LzWzcNHA8J
k3vC4mTaihD5sLNgFavJ1HT++XM+mwWInzrrWKAToS/LZ++kx+gdXSc3bv8Rgblz
7ByxRDgWZzfrDi+89BOWcrP37A8Ki0Fm5ttUzds+ka/7BE/Q0zu67iXe3beggSBB
VucaVT7tFRwFWLXFyUKl42SLADxOTHMI1Sq6ORczYuBV40zFZ84BbSud0O4i84IJ
zQHnjadMZXCBK/d9q2W+6gnywljWjconFJmFY1jpbQ7OR32tc9J4s2+ecor6BY4X
JLcDzccmPPtT77UBdGQt4g3Y4vcgCGUSJlL6GYqPXCiqp1f6FcrYdbO2kCMpy9BW
BHRBgzd43Qo9Y6tKM/BjFcgJJBjVLlQoFYTZw3ggk6GA/UQz2qKEKyg35PuxMSVJ
lVM6Mq9lsREar3If3K0g+On3kH9V09VUIr1q4OUpvAJ6BsOoDsA=
=7DCg
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by "André Warnier (tomcat/perl)" <aw...@ice-sa.com>.
On 22.01.2020 10:26, Lmhelp1 wrote:
> Hello Chris and all,
>
> Sorry for my late answer.
> Thank you for the link you suggested me to read.
> Adding the element:
> <request-character-encoding>UTF-8</request-character-encoding>
> to "web.xml" solved my problem.
>
Glad to hear that.
From an absolute point of view, this is of course again a "patch". But as Chris pointed
out before, it is unfortunately an unavoidable one, due to the fact that the browsers
lamentably fail to always indicate the character set and encoding that they are using for
sending text data to the server.
[RANT:]
(Although they know, and although the specifications provide them with an easy way to do
that. Why that is so is anyone's guess, but the economic losses due to that over the years
must be staggering).
(probably close to the cost of allowing spaces in directories and files names)
>
>
> On 17/01/2020 3:17 PM, Christopher Schultz wrote:
>> Your filter changes the encoding of both the request AND the response.
>> It's likely that fixing the request-encoding was necessary, while
>> changing the response-encoding was not.
>>
>> The problem is:
>>
>> 1. The official RFC-defined default character encoding for HTTP is
>> ISO-8859-1.
>>
>> 2. The browser default appears to be unpredictable, but often UTF-8.
>>
>> 3. The browsers have all agreed not to tell the server what characted
>> encoding is actually being used.
>>
>> It's fun. It's a very simply-solved problem: the browser should just
>> advertise the character encoding and everything would be great. Sadly, n
>> o.
>>
>> I would encourage you to read this page in its entirety:
>> https://cwiki.apache.org/confluence/display/TOMCAT/Character+Encoding
>>
>> - -chris
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Lmhelp1 <lm...@orange.fr>.
Hello Chris and all,
Sorry for my late answer.
Thank you for the link you suggested me to read.
Adding the element:
<request-character-encoding>UTF-8</request-character-encoding>
to "web.xml" solved my problem.
Best regards,
--
Léa
On 17/01/2020 3:17 PM, Christopher Schultz wrote:
> Your filter changes the encoding of both the request AND the response.
> It's likely that fixing the request-encoding was necessary, while
> changing the response-encoding was not.
>
> The problem is:
>
> 1. The official RFC-defined default character encoding for HTTP is
> ISO-8859-1.
>
> 2. The browser default appears to be unpredictable, but often UTF-8.
>
> 3. The browsers have all agreed not to tell the server what characted
> encoding is actually being used.
>
> It's fun. It's a very simply-solved problem: the browser should just
> advertise the character encoding and everything would be great. Sadly, n
> o.
>
> I would encourage you to read this page in its entirety:
> https://cwiki.apache.org/confluence/display/TOMCAT/Character+Encoding
>
> - -chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Léa,
On 1/17/20 8:48 AM, Lmhelp1 wrote:
> Hello,
>
> Thank you for your answer.
>
> So, I removed the filter from "web.xml".
>
> Now, some characters with diacritics are rendered properly (for
> example constant strings like menu entries: "Présentation").
>
> But I created a new user "Léa": I entered "Léa" in a input type
> text HTML element and submitted the form in which was the input
> element. Now "Léa" is rendered as "Léa" when I need to dipslay it
> either back in an input or as text in a "div".
>
> The filter that I put in 2015 in the Webapp (I don't really
> remember how, I guess I had the same problem at the time) prevented
> such things from happening.
Your filter changes the encoding of both the request AND the response.
It's likely that fixing the request-encoding was necessary, while
changing the response-encoding was not.
The problem is:
1. The official RFC-defined default character encoding for HTTP is
ISO-8859-1.
2. The browser default appears to be unpredictable, but often UTF-8.
3. The browsers have all agreed not to tell the server what characted
encoding is actually being used.
It's fun. It's a very simply-solved problem: the browser should just
advertise the character encoding and everything would be great. Sadly, n
o.
I would encourage you to read this page in its entirety:
https://cwiki.apache.org/confluence/display/TOMCAT/Character+Encoding
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4hwhQACgkQHPApP6U8
pFixlRAAxZzJiGd/uqbehT1qF7BF2Bff7KfiAxqmCzohjwEv2S6mSDw9t7EiV744
oNlPTiXeok6Rt+gH5TNpSAtFXFPSpr2IKP42FjwmXjJabdHfByZrUor65TIfZCfS
DbzHVsRm4YPBobeEtwNVtIhYbcdEt0/qP4QticyNo/mXh1aHA1q0HPvcvNrJeYgn
RAgrhUUxZnU+TQvB6GbX06/70LRz42H4jsxxI+MA7cmy/i1JejJ4RQad6LE85fuO
kmeZea0XohrjnJevE2vjpuTmI02+j7IJKWgaIWfKUWgys64VG4L1O6u6RG4Wzku5
V9yi7kHI46PFUVAABykmsybZV1kH7nqQoAX/h8RxhZToFCowtahYDstyoNe2Zy8S
Q80RtgyLwo8OviQIat0F9SeZG47EZ7KRzlvYLUNad/eGpW5jKXyktyXB4nk9qXdY
Uk2xWiYxa4krCh+Ug7YMBooYvmHAL9Ch6AuLQDezzngTGC1Gt8IPxYZ/Jltducce
6IvVWDIDsu3D6AXCedmg2CldgdxYMA1Q2EoYWym/bPkE8Fynltuo5nE+BOPHU+k+
/zapbocbRJ7xFAVuJ6XNQUfC4vYHofg68s8W6LOfpQqFM/bjvyOp2vWX1MQ0zKzh
SSaBl7NnysRCAHsgJcvqpIRwGZKvBHBiqU10d0ZaPLzU8m31DMY=
=Uf+6
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Lmhelp1 <lm...@orange.fr>.
Hello,
Thank you for your answer.
So, I removed the filter from "web.xml".
Now, some characters with diacritics are rendered properly (for example
constant strings like menu entries: "Présentation").
But I created a new user "Léa": I entered "Léa" in a input type text
HTML element and submitted the form in which was the input element.
Now "Léa" is rendered as "Léa" when I need to dipslay it either back in
an input or as text in a "div".
The filter that I put in 2015 in the Webapp (I don't really remember
how, I guess I had the same problem at the time) prevented such things
from happening.
Please help.
Thanks,
--
Léa
On 17/01/2020 9:36 AM, André Warnier (tomcat/perl) wrote:
> I believe Chris had a bit too much - or too little - coffee when he
> wrote the above, and that he meant :
>
> 1. Delete the *filter*and remove all references to it in web.xml
> 2. ...
>
> The point is : if your application is well-written and follows the
> standards, you should not normally need this Encoding filter, and
> everything should "just work". This filter is probably a left-over
> "patch" from either an older (and incorrect) application version, or
> some older version of Tomcat.
>
> That is why I first recommended that you remove the whole filter
> section from your web.xml, and check what happens. Display some pages
> which /should/contain some text in non-English languages (meaning with
> "diacritics" like è, é, à, ü, ö, ..) and if they display correctly,
> there is nothing else to do.
>
> Only if you /do/get a wrong display of some of that data, then you
> should come back here, and try to describe what is wrong. And we could
> then help you find the root cause.
> That would be better than trying to apply a patch over a patch over a
> patch..
Re: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by "André Warnier (tomcat/perl)" <aw...@ice-sa.com>.
On 17.01.2020 04:15, Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Léa,
>
> On 1/16/20 9:33 AM, Lmhelp1 wrote:
>> Hello,
>>
>> Thank you for your answers.
>>
>> I changed <url-pattern>/*</url-pattern> to
>> <url-pattern>*.jsp</url-pattern> I also un-commented the line:
>> servletResponse.setContentType("text/html; charset=" +
>> Finals.S_CHARSET);
>>
>> It looks like the problem is solved.
>>
>> [snip]
>>
>> Shall I leave <url-pattern>*.jsp</url-pattern> as it is, or can
>> you suggest another pattern?
>
> There is a better solution:
>
> 1. Delete the files and removed references to it in web.xml
>
> 2. Edit your JSP files and properly set the content-type and encoding
> in the @page directive at the top of the file.
>
I believe Chris had a bit too much - or too little - coffee when he wrote the above, and
that he meant :
1. Delete the *filter* and remove all references to it in web.xml
2. ...
The point is : if your application is well-written and follows the standards, you should
not normally need this Encoding filter, and everything should "just work". This filter is
probably a left-over "patch" from either an older (and incorrect) application version, or
some older version of Tomcat.
That is why I first recommended that you remove the whole filter section from your
web.xml, and check what happens. Display some pages which /should/ contain some text in
non-English languages (meaning with "diacritics" like è, é, à, ü, ö, ..) and if they
display correctly, there is nothing else to do.
Only if you /do/ get a wrong display of some of that data, then you should come back here,
and try to describe what is wrong. And we could then help you find the root cause.
That would be better than trying to apply a patch over a patch over a patch..
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Léa,
On 1/16/20 9:33 AM, Lmhelp1 wrote:
> Hello,
>
> Thank you for your answers.
>
> I changed <url-pattern>/*</url-pattern> to
> <url-pattern>*.jsp</url-pattern> I also un-commented the line:
> servletResponse.setContentType("text/html; charset=" +
> Finals.S_CHARSET);
>
> It looks like the problem is solved.
>
> [snip]
>
> Shall I leave <url-pattern>*.jsp</url-pattern> as it is, or can
> you suggest another pattern?
There is a better solution:
1. Delete the files and removed references to it in web.xml
2. Edit your JSP files and properly set the content-type and encoding
in the @page directive at the top of the file.
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4hJroACgkQHPApP6U8
pFhnMRAAkQSTBhK6okaq3iyZFnTY1n7cGM6iOxO3llWU1CTFgoae9Z4U/d0tXCEc
jpMj+ymmGSfgJxyidNJAQSrVU8bFulTKwPvPeaXylLJ5twO/NigzSfYAoTredBpC
zywp6ddQLYaK2r+/PAixIV+afDIEh2VEmrZo/vNUfgxo/8rZWrcGp8f5xSxXebXS
0Cww/6oFR0z1J9nnv9DRyxj5uKOUqOKfCoh2hyuJcoKWHMG/2knLVx5WcZSd+NJe
cRWVNxdmriL7FT+4ywK39Y03FRegvAusFTnwDmjyImmFPKinssGFBSKuOrWkH6XN
yDehvqU5HnURqGBOUm2ABl2EJQmpu+s217DdEy8WZcGHsWLFZYl9SuL5wtxRAj/L
K62tGeIgykPV2NMTM+PMi6AymzMhNQllsLFl29bYZPm3tmnwvbDoTGIXNyGs8StU
pTloCtQj354aEv/1fuaNb0WzjsVd+WYRAsf2Wy4rh4mV1HFhGGJvXADmzFgNgFQI
bSNWCQTUWUOtKElbfzcTY/BqOHnmIRFZJe5zdRjL7fcug4ograyYLylFvSt/HJoB
K3sH1RZKLFywrGk1VszRuvgVVQF72MfpHkCrq1bbZxtkR9d5WzI9CFUXI8aXKV2b
OgY1SefZb6pYSQcxbWQFdRzoxkkKH8wnfPkEY4A2MUqR7DTw4WY=
=3osL
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Lmhelp1 <lm...@orange.fr>.
Hello,
Thank you for your answers.
I changed <url-pattern>/*</url-pattern> to <url-pattern>*.jsp</url-pattern>
I also un-commented the line:
servletResponse.setContentType("text/html; charset=" + Finals.S_CHARSET);
It looks like the problem is solved.
> André Warnier wrote:
> As another way of avoiding that problem, you may also want to change
in web.xml :
> <url-pattern>/*</url-pattern>
> by something that applies *only*to HTML responses.
Shall I leave <url-pattern>*.jsp</url-pattern> as it is, or can you
suggest another pattern?
Thank you and best regards,
--
Léa
On 16/01/2020 11:24 AM, André Warnier (tomcat/perl) wrote:
> Also note :
> https://tomcat.apache.org/tomcat-9.0-doc/servletapi/javax/servlet/ServletResponse.html#setCharacterEncoding-java.lang.String-
>
>
> says :
>
> "...calling this method with the String of UTF-8 is equivalent with
> calling setContentType with the String of text/html; charset=UTF-8."
>
> So, in the above, if you have just commented-out the line :
>
> servletResponse.setContentType("text/html; charset=" +
> Finals.S_CHARSET);
>
> but you left the following line unchanged
>
> servletResponse.setCharacterEncoding(Finals.S_CHARSET);
>
> then executing this line is equivalent to setting the content type to
> "text/html".
> And this looks suspiciously like the error you are getting..
>
> As another way of avoiding that problem, you may also want to change
> in web.xml :
>
> > <url-pattern>/*</url-pattern>
>
> by something that applies *only*to HTML responses.
Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by "André Warnier (tomcat/perl)" <aw...@ice-sa.com>.
On 16.01.2020 10:36, Lmhelp1 wrote:
> Hello,
>
> Thank you for your answer.
> Indeed, I have such a filter:
>
> In "web.xml":
> ----------------------------------------------------------------------------------------
> <filter>
> <filter-name>EncodingFilter</filter-name>
> <filter-class>com.[...].EncodingFilter</filter-class>
> <init-param>
> <param-name>requestEncoding</param-name>
> <param-value>UTF-8</param-value>
> </init-param>
> </filter>
> <filter-mapping>
> <filter-name>EncodingFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
> ----------------------------------------------------------------------------------------
>
> The "doFilter()" method of the "EncodingFilter" class which implements "Filter":
> ----------------------------------------------------------------------------------------
> public void doFilter(ServletRequest servletRequest,
> ServletResponse servletResponse,
> FilterChain filterChain)
> throws IOException, ServletException
> {
> // Respect the client-specified character encoding
> // (see HTTP specification section 3.4.1)
> if(servletRequest.getCharacterEncoding() == null)
> {
> servletRequest.setCharacterEncoding(ms_encoding);
> }
>
> // Set the default response content type and encoding
> servletResponse.setContentType("text/html; charset=" + Finals.S_CHARSET);
> servletResponse.setCharacterEncoding(Finals.S_CHARSET);
>
> filterChain.doFilter(servletRequest, servletResponse);
> }
> ----------------------------------------------------------------------------------------
>
> Commenting the line:
> servletResponse.setContentType("text/html; charset=" + Finals.S_CHARSET);
> doesn't solve the problem.
> I still get the error:
> ----------------------------------------------------------------------------------------
> The stylesheet http ://localhost/fr/css/fo.css was not loaded because itsMIME type,
> “text/html”, is not “text/css”.
> ----------------------------------------------------------------------------------------
>
Also note :
https://tomcat.apache.org/tomcat-9.0-doc/servletapi/javax/servlet/ServletResponse.html#setCharacterEncoding-java.lang.String-
says :
"...calling this method with the String of UTF-8 is equivalent with calling setContentType
with the String of text/html; charset=UTF-8."
So, in the above, if you have just commented-out the line :
servletResponse.setContentType("text/html; charset=" + Finals.S_CHARSET);
but you left the following line unchanged
servletResponse.setCharacterEncoding(Finals.S_CHARSET);
then executing this line is equivalent to setting the content type to "text/html".
And this looks suspiciously like the error you are getting..
As another way of avoiding that problem, you may also want to change in web.xml :
> <url-pattern>/*</url-pattern>
by something that applies *only* to HTML responses.
> Best regards,
> --
> Léa
>
>
> On 15/01/2020 5:09 PM, Niall Fitzpatrick wrote:
>> 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Lmhelp1 <lm...@orange.fr>.
Hello,
Thank you for your answer.
Indeed, I have such a filter:
In "web.xml":
----------------------------------------------------------------------------------------
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>com.[...].EncodingFilter</filter-class>
<init-param>
<param-name>requestEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
----------------------------------------------------------------------------------------
The "doFilter()" method of the "EncodingFilter" class which implements
"Filter":
----------------------------------------------------------------------------------------
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse,
FilterChain filterChain)
throws IOException, ServletException
{
// Respect the client-specified character encoding
// (see HTTP specification section 3.4.1)
if(servletRequest.getCharacterEncoding() == null)
{
servletRequest.setCharacterEncoding(ms_encoding);
}
// Set the default response content type and encoding
servletResponse.setContentType("text/html; charset=" +
Finals.S_CHARSET);
servletResponse.setCharacterEncoding(Finals.S_CHARSET);
filterChain.doFilter(servletRequest, servletResponse);
}
----------------------------------------------------------------------------------------
Commenting the line:
servletResponse.setContentType("text/html; charset=" + Finals.S_CHARSET);
doesn't solve the problem.
I still get the error:
----------------------------------------------------------------------------------------
The stylesheet http ://localhost/fr/css/fo.css was not loaded because
itsMIME type, “text/html”, is not “text/css”.
----------------------------------------------------------------------------------------
Best regards,
--
Léa
On 15/01/2020 5:09 PM, Niall Fitzpatrick wrote:
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Niall Fitzpatrick <ni...@live.co.uk>.
________________________________
From: Peter Köhler <pe...@dw.com>
Sent: 15 January 2020 14:49
To: Tomcat Users List <us...@tomcat.apache.org>
Subject: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox
Von: Léa Massiot <lm...@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@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
Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox
Posted by Peter Köhler <pe...@dw.com>.
Von: Léa Massiot <lm...@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Dear Lea,
maybe
https://stackoverflow.com/questions/48248832/stylesheet-not-loaded-because-of-mime-type
helps.
Regards
Peter