Categories
Development

Charactersets and internationalisation in J2EE

Internationalisation and character sets can be a pain in the ass. I avoid it as much as I can, and did until today because I reconed Java always runs UTF-16 and that it shouldn’t be a problem. 😉 It does run UTF-16 internally always, but the transition from webrequests into the JVM can be a bit tricky.

We need to accept special characters for all of Europe, and got tons of errors when we finally started testing with Greek characters. I found a couple of articles describing it that helped me solve it:

It surprised me a bit that the web-client does not specify which encoding it submits back in. If the page that was received from the server and is beeing submitted, is in UTF-8 the client submits back UTF-8. But because it doesn’t specify the encoding on submit, the webserver must know/remember which encoding the pages were sent out in. This is not done by default in J2EE, so the encoding in the request is set to null. Because we run UTF-8 on all our pages (which is recommended practice), we just set the encoding in a filter for each request. If you have different users that might use different encodings you’ll have to keep track of it in a session or something like that.

Categories
Development

Church of POJO

I’m not much of a fan of religious imagery, but Adrian Colyer has a really good way of explaining and illustrating how Dependency Injection, Aspects and Annotations can work together to support a loosely copuled POJO model here. Also some good reference links, go read.

Via Dion.

Categories
Development

Ajax again

Been some buzz lately about Ajax applications. Found this framework called SAJAX that lets you expose PHP methods as callable methods under a Ajax regime.

Matt Raible and Dion Almaer has some thoughts on Ajax too.