Servlets and charsets

M

Marius Waldal

I have a servlet receiving http-connections from different sources. Some of
these use UTF-8 charset and some use ISO-8859-1 (and I can't influence
this). How can I handle this in the servlet?

I specify the charset based on a configuration, like this:

isr = new InputStreamReader( req.getInputStream(), bbEConfig.strCharSet );

But this only works if the config charset equals the connecting server's
charset, of course.

I've tried using the getCharacterEncoding method in the ServletRequest
class, but is this always set? Or is it only set if the connecting
server/application has explicitly set it?

In summary: how do I dynamically determine which charset to use?

Marius
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top