Specifying UTF-8 encoding when starting Jetty solved the problem.
java -Dfile.encoding=UTF-8 -jar start.jar
Also, here is the Chef cookbook I use in case it helps you: https://github.com/bluemont/chef-jetty
Question
My HTML entities, such as ©
and mdash;
are showing up as ?, both when rendered on the page and when I view the underlying source -- but only when served through my production Jetty server (in the webapps
directory).
The HTML entities look fine in when served from static files through a local Nginx. They also look good when run through a development run of a Pedestal app using embedded Jetty. Here is the HTML head:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta content="Web Site Description" name="description" />
<meta content="The Author" name="author" />
<link href="/images/favicon-128x128.png" type="image/png" rel="shortcut icon" />
<title>A Really Great Title</title>
<link rel="stylesheet" href="/css/bootstrap.css" />
<link rel="stylesheet" href="/css/shared.css" />
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js">
</script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js">
</script>
<![endif]-->
</head>
How do I solve this? What might be going wrong? Or, failing that, how do I debug?
Some ideas:
First, I'm using Jetty 9.1.X in production. My development server uses (from lein deps :tree
):
[io.pedestal/pedestal.jetty "0.2.2"]
[javax.servlet/javax.servlet-api "3.0.1"]
[org.eclipse.jetty/jetty-server "8.1.9.v20130131"]
[org.eclipse.jetty.orbit/javax.servlet "3.0.0.v201112011016"]
[org.eclipse.jetty/jetty-continuation "8.1.9.v20130131"]
[org.eclipse.jetty/jetty-http "8.1.9.v20130131"]
[org.eclipse.jetty/jetty-io "8.1.9.v20130131"]
[org.eclipse.jetty/jetty-util "8.1.9.v20130131"]
[org.eclipse.jetty/jetty-servlet "8.1.9.v20130131"]
[org.eclipse.jetty/jetty-security "8.1.9.v20130131"]
Are there Jetty 9 production settings I should double check?
Second, I'm using Enlive. It relies on the following dependencies (from lein deps :tree
):
[enlive "1.1.5"]
[org.ccil.cowan.tagsoup/tagsoup "1.2.1"]
[org.jsoup/jsoup "1.7.2"]
I wonder if somehow TagSoup is behaving differently in production versus development.
Update:
Here are the response headers:
HTTP/1.1 200 OK
Set-Cookie: ring-session=eyTI ... <SNIP> ... s%3D;Path=/
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Server: Jetty(9.1.3.v20140225)
The text/html;charset=UTF-8
seems to rule out that Jetty is the problem. I think it is possible (even likely) that TagSoup is not behaving as I would expect.
I am currently reading this thread on the Enlive mailing list: mdash output as question mark.
Update: My Clojure templating (I was using Enlive but I just switched to Laser -- but both behave the same in this regard) converts the HTML entities to Unicode. The problem seems to be that my installation Jetty 9 is not configured (or I'm not giving it what it needs) to handle the Unicode characters.
La solution
Specifying UTF-8 encoding when starting Jetty solved the problem.
java -Dfile.encoding=UTF-8 -jar start.jar
Also, here is the Chef cookbook I use in case it helps you: https://github.com/bluemont/chef-jetty