JNB
rss

skin by 이글루스

JAVA & JSP

glassfish_How can I specify the encoding of HTTP request parameters 11.10.18 19:59

GlassFish treats the encoding of a request's URI separately from the encoding of its parameters. In the case of a GET request, query parameters are appended to the URI (separated by ?), whereas in the case of a POST request, they are carried inside the request body.

The two types of encoding are specified in different places:

  • The URI encoding may be specified as the value of a property named uriEncoding of the <http-listener> element in domain.xml. This encoding, which defaults to UTF-8, is applied to any request URI received by the corresponding HTTP listener.
  • The request parameter encoding, on the other hand, defaults to ISO-8859-1 and may be overridden in one of two places: Either programmatically inside a servlet, by calling the ServletRequest's setCharacterEncoding method, or declaratively, by specifying the parameter encoding as the value of the default-charset attribute of the <parameter-encoding> element in sun-web.xml, as shown in the following example, which sets the request's parameter encoding to UTF-8:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 8.0 Servlet 2.4//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_4-0.dtd">

<sun-web-app>
  <locale-charset-info default-locale="">
    <locale-charset-map locale="" charset=""/>
    <parameter-encoding default-charset="UTF-8"/>
  </locale-charset-info>
</sun-web-app>

        

    
Copyright 1999-2018 Zeroboard / skin by JY