Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Setting text/javascript encoding to utf8 with Jetty 10.0.16

Here's an alternate way to set it up.

My jetty-base ...

[demo-jersey-2]$ tree -F
demo-jersey-2/
├── resources/
│   └── jetty-logging.properties
├── start.d/
│   ├── deploy.ini
│   └── http.ini
└── webapps/
    └── jersey.war

This is pretty much all defaults on Jetty.
I have enabled the modules http,deploy only.
If I start this jetty-base and check a _javascript_, I see what you see.

$ curl --dump-header - -o /dev/null http://localhost:8080/jersey/js/engine.js
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
HTTP/1.1 200 OK
Last-Modified: Sat, 19 Dec 2020 23:24:00 GMT
Content-Type: text/_javascript_
Accept-Ranges: bytes
Content-Length: 2669
Server: Jetty(10.0.16)

100  2669  100  2669    0     0  31086      0 --:--:-- --:--:-- --:--:-- 31400

Now if I add a webapps/jetty.xml that has the following contents ...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure id="webapp" class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/jersey</Set>
  <Set name="war"><Property name="jetty.webapps" default="." />/jersey.war</Set>
  <Get name="mimeTypes">
    <Call name="addMimeMapping">
      <Arg>js</Arg>
      <Arg>text/_javascript_;charset=UTF-8</Arg>
    </Call>
  </Get>
</Configure>

Which makes the jetty-base look like this ...

[demo-jersey-2]$ tree -F
demo-jersey-2/
├── resources/
│   └── jetty-logging.properties
├── start.d/
│   ├── deploy.ini
│   └── http.ini
└── webapps/
    ├── jersey.war
    └── jersey.xml

Now when I start this jetty-base and access the same _javascript_, I see this ...

$ curl --dump-header - -o /dev/null http://localhost:8080/jersey/js/engine.js
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
HTTP/1.1 200 OK
Last-Modified: Sat, 19 Dec 2020 23:24:00 GMT
Content-Type: text/_javascript_;charset=utf-8
Accept-Ranges: bytes
Content-Length: 2669
Server: Jetty(10.0.16)

100  2669  100  2669    0     0  30899      0 --:--:-- --:--:-- --:--:-- 31034

Which includes the charset.

Joakim Erdfelt / joakim@xxxxxxxxxxx

Back to the top