NextApp Echo
App Container 1.0.5

nextapp.echoservlet
Class ServletEncodingAdapter

java.lang.Object
  extended bynextapp.echoservlet.ServletEncodingAdapter

class ServletEncodingAdapter
extends java.lang.Object

A utility class which fixes character encoding issues which occur during HTTP transactions as a result of browsers not properly setting the character encoding of their requests.


Field Summary
private  boolean encodingCorrectionRequired
          Indicates whether character encoding must be corrected on request parameters.
private  boolean mutableRequestEncoding
          Indicates whether the servlet container supports the ServletRequest.setCharacterEncoding() method.
private static boolean SERVLET_2_2_TEST_MODE
           
private  java.lang.String servletContainerDefaultEncoding
          The servlet container's default character encoding.
private  java.lang.reflect.Method setCharacterEncodingMethod
          A reflection reference to the ServletRequest.setCharacterEncoding() method.
 
Constructor Summary
(package private) ServletEncodingAdapter(EchoServer server)
          Creates a new ServletEncodingAdapter for an EchoServer.
 
Method Summary
(package private)  java.lang.String getParameter(javax.servlet.ServletRequest request, java.lang.String parameterName, java.lang.String encoding)
          Returns a parameter value from a ServletRequest, performing any necessary character encoding corrections.
(package private)  void setRequestCharacterEncoding(javax.servlet.ServletRequest request, java.lang.String encoding)
          Sets the character encoding of a ServletRequest, if the operation is supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVLET_2_2_TEST_MODE

private static final boolean SERVLET_2_2_TEST_MODE
See Also:
Constant Field Values

mutableRequestEncoding

private boolean mutableRequestEncoding
Indicates whether the servlet container supports the ServletRequest.setCharacterEncoding() method.


encodingCorrectionRequired

private boolean encodingCorrectionRequired
Indicates whether character encoding must be corrected on request parameters.


servletContainerDefaultEncoding

private java.lang.String servletContainerDefaultEncoding
The servlet container's default character encoding. This is the encoding with which the container will encode strings by default if the browser has not set the encoding and the encoding has not been set via ServletRequest.setCharacterEncoding().


setCharacterEncodingMethod

private java.lang.reflect.Method setCharacterEncodingMethod
A reflection reference to the ServletRequest.setCharacterEncoding() method.

Constructor Detail

ServletEncodingAdapter

ServletEncodingAdapter(EchoServer server)
Creates a new ServletEncodingAdapter for an EchoServer.

Parameters:
server - The EchoServer.
Method Detail

getParameter

java.lang.String getParameter(javax.servlet.ServletRequest request,
                              java.lang.String parameterName,
                              java.lang.String encoding)
                        throws java.io.UnsupportedEncodingException
Returns a parameter value from a ServletRequest, performing any necessary character encoding corrections.

Parameters:
request - The ServletRequest containing the parameter.
parameterName - The name of the parameter to return.
encoding - The proper encoding of the parameter.
Returns:
The correctly encoded value of the parameter.
Throws:
java.io.UnsupportedEncodingException

setRequestCharacterEncoding

void setRequestCharacterEncoding(javax.servlet.ServletRequest request,
                                 java.lang.String encoding)
                           throws java.io.UnsupportedEncodingException
Sets the character encoding of a ServletRequest, if the operation is supported.

Parameters:
request - The ServletRequest to be configured.
encoding - The character encoding.
Throws:
java.io.UnsupportedEncodingException

NextApp Echo
App Container 1.0.5