Hi:
>>I was expecting to find getCharacterEncoding() on the ServletRequest and setCharacterEncoding(...) on the ServletResponse...... It sounds quite logical to expect ServletRequest interface to have getCharacterEncoding() only and ServletResponse interface to have a similar method for setting charset, say setCharacterEncoding(
String var).
As we know, ServletRequest has setCharacterEncoding(String env) method inaddtion to getCharacterEncoding(). The spec gives a good reason for including setCharacterEncoding(String env) in ServletRequest interface.
If the client (i.e browser) does not send a character encoding qualifier, it is upto the container to decide the character encoding and the container uses the default encoding (ISO-8859-I). Here, if the request data is encoded with a different encoding other than the default, breakage occurs. To avoid this, setCharacterEncoding method has been added so that the devloper can override the character encoding suppiled by the container by calling this method. And, this method should be called before any input is read from the request.
Now coming to ServletResponse, for getting the character encoding it has getCharacterEncoding() and for setting charset, it has the following two methods.
setContentType(String type) - here type is the MIME type
setLocale(Locale loc) - loc is the locale of the response
Hope this is clear,
Gaja Venkat
-------------------------------------------
Sun Certfied Programmer for
Java 2 Platform
[ March 06, 2002: Message edited by: Gaja Venkat ]