Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox

2020-01-16 Thread Christopher Schultz
-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": 
> --
- --
>
>   EncodingFilter 
> com.[...].EncodingFilter  
> requestEncoding 
> UTF-8   
>  EncodingFilter 
> /*  
> --
- --
>
> 
> 
> 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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox

2020-01-16 Thread tomcat/perl

On 16.01.2020 10:36, Lmhelp1 wrote:

Hello,

Thank you for your answer.
Indeed, I have such a filter:

In "web.xml":

  
     EncodingFilter
com.[...].EncodingFilter
     
requestEncoding
   UTF-8
     
   
   
     EncodingFilter
     /*
   


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 
:

>  /*

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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox

2020-01-16 Thread tomcat/perl

On 16.01.2020 10:36, Lmhelp1 wrote:

Hello,

Thank you for your answer.
Indeed, I have such a filter:

In "web.xml":







[...]

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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox

2020-01-16 Thread Lmhelp1

Hello,

Thank you for your answer.
Indeed, I have such a filter:

In "web.xml":

 
    EncodingFilter
com.[...].EncodingFilter
    
requestEncoding
  UTF-8
    
  
  
    EncodingFilter
    /*
  


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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox

2020-01-15 Thread Niall Fitzpatrick



From: Peter Köhler 
Sent: 15 January 2020 14:49
To: Tomcat Users List 
Subject: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox

Von:Léa Massiot 
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//.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//.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"%>



  








  ${initParam['S_IF_MSG_TITLE_WELCOME']}



  
--

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


Fw: Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox

2020-01-15 Thread Peter Köhler
- Weitergeleitet von Peter Köhler/BN/DWD am 15.01.2020 15:50 -

Von:Peter Köhler 
An: "Tomcat Users List" 
Datum:  15.01.2020 15:49
Betreff:Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox



Von:Léa Massiot 
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//.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//.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"%>



  





 


  ${initParam['S_IF_MSG_TITLE_WELCOME']}



  
--

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




Antwort: Tomcat9, JSP, CSS and JS not loading in Firefox

2020-01-15 Thread Peter Köhler
Von:Léa Massiot 
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//.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//.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"%>



  





 


  ${initParam['S_IF_MSG_TITLE_WELCOME']}



  
--

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