Can I set a charset on my response dynamically in a JSP? I want to set the content type to have a charset that can represent characters in a particular language in an I18N'ed application--Big5, ISO-8859-5, etc.

Kenneth Tang

Yes, you can set it dynamically. Set the encoding in contentType like this:

response.setContentType("text/html; charset=UTF-8");

UTF-8 will be much simplier in terms of programming effort. But it may cause some minor display problems for some browsers as the Unicode fonts may not be available.

If using native encoding, such as Big5, you should not have a display problem. But you may need extra programming efforts when there is forms (user input) in the page, as the parameter is returned in the same encoding of the page.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact