I’m writing a little web application to help me learn some German (yeah, a bit of yak-shaving) and I wanted to deploy it locally using an executable jar. I wrote about how to do this previously using winstone and that worked pretty well. Unlike dealing with a normal English character set, dealing with letters like ß, Ä, Ü and Ö are pretty important.

It looks like, by default, serving static HTML from winstone doesn’t seem to work unless you explicitly specify the character encoding as UTF-8. A simple web-filter applied to all URLs helps us here. Here’s an example in scala:

import javax.servlet._

class ForceUtf8EncodingFilter extends Filter {
  def doFilter(request:ServletRequest, response : ServletResponse, chain: FilterChain) {
    response.setCharacterEncoding("UTF-8")
    chain.doFilter(request, response)
  }

  def init(config: FilterConfig) { }

  def destroy() { }
}