My proposal to Servlet and JSP Specification > My proposal
Previous Page Contents Next Page
OOP-Reserch home page

Mail to Me

My proposal

Any questions and comments are welcome to me.

2. My proposal to Servlet Specification

It is safe to move the responsibility to determine the charset from the server developer to the servlet writer. The practical solution to the problem above is to provide the servlet writer with the chance to determine the charset. Adding the following new method to HttpServletRequest will be enough:

The parameter 'String enc' may be the Java character encoding (just as with the case of String(byte[] byts, String enc)) or the charset code of RFC2616.
Given the charset by the servlet writer, the server implementation can returns the original parameter string(s) (or names). Note that if the 'charset' attribute is present in the 'Content-type' header sent by the WWW client, the Java character encoding (or RFC2616 charset) specified by these methods should be ignored.

The new method must be called before the servlet writer gets parameter string(s) or names by the following methods: If the Java character encoding (or RFC2616 charset) is not set by the servlet writer, the server implementation should create the parameter string based on the charset retrieved by any ways listed in 1.3, rather than the default Java character encoding based on the runtime environment (which is retrieved by ByteToCharConverter.getDefault().getCharacterEncoding()).

3. My proposal to JSP Specification

My proposal to Servlet Specification described above is also applied to JSP specification.

JSP writer can set the Java character encoding (or RFC2616 charset) by:

    request.setCharacterEncoding(String enc);
(Note that 'request' is one of the implicit object, which represents the instance of HttpServletRequest.)

But it is preferable to define the new page directive, such as
    <%@ page requestEncoding="Shif_JIS" %>
With this directive is specified, all the parameter values passed to the JavaBeans instance by:
    <jsp:setProperty name="xxx" property="yyy" />
can be same as the original one.

4. About HttpServletResponse

As for HttpServletResponse, the servlet writer knows in which 'charset' the content should be sent to the client. And s/he can get the appropriate 'Writer' by calling 'setLocale()' or 'setContentType()' before 'getWriter()'. This is described clearly in

of Servlet Specification v2.2. As long as I know, the developers of Tomcat seems to be content with this spec and Tomcat is implemented in this way.

5. I need your opinion!

I'm eager for your opinion to my proposal!

Java and all Java-based trademarks and logos are trademarks or registered of Sun Microsystems, Inc. in the United States and other countries.


Previous Page Contents Next Page
OOP-Reserch home page

Mail to Me


ALL CONTENTS COPYRIGHT 2000 , Jun Inamori. All rights reserved.
Any questions and comments are welcome to Jun Inamori .