User Tools

Site Tools


glassfish_uri_parameter_encoding

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

glassfish_uri_parameter_encoding [2014/03/06 08:44]
mihael created
glassfish_uri_parameter_encoding [2014/03/06 08:47] (current)
mihael
Line 4: Line 4:
  
 How can I specify the encoding of HTTP request parameters? How can I specify the encoding of HTTP request parameters?
-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 <​code>​?</​code>​), whereas in the case of a POST request, they are carried inside the request body.+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 two types of encoding are specified in different places:
  
-* The URI encoding may be specified as the value of a property named <​code>​uriEncoding</​code> ​of the <​code>​<​http-listener>​</​code> ​element in <​code>​domain.xml</​code>​. This encoding, which defaults to <​code>​UTF-8</​code>​, is applied to any request URI received by the corresponding HTTP listener. +  ​* 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 <​code>​ISO-8859-1</​code> ​and may be overridden in one of two places: Either programmatically inside a servlet, by calling the ServletRequest'​s ​<​code>​setCharacterEncoding</​code> ​method, or declaratively,​ by specifying the parameter encoding as the value of the <​code>​default-charset</​code> ​attribute of the <​code>​<​parameter-encoding>​</​code> ​element in <​code>​sun-web.xml</​code>​, as shown in the following example, which sets the request'​s parameter encoding to <​code>​UTF-8</​code>​:+  * 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''​:
  
 <sxh xml> <sxh xml>
 <?xml version="​1.0"​ encoding="​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"​+<​!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">​  "​http://​www.sun.com/​software/​sunone/​appserver/​dtds/​sun-web-app_2_4-0.dtd">​
    
Line 28: Line 29:
 <sxh xml> <sxh xml>
 <?xml version="​1.0"​ encoding="​UTF-8"?>​ <?xml version="​1.0"​ encoding="​UTF-8"?>​
-<​!DOCTYPE glassfish-web-app PUBLIC "​-//​GlassFish.org//​DTD GlassFish Application Server 3.1 Servlet 3.0//​EN"​ "​http://​glassfish.org/​dtds/​glassfish-web-app_3_0-1.dtd">​+<​!DOCTYPE glassfish-web-app ​ 
 +  ​PUBLIC "​-//​GlassFish.org//​DTD GlassFish Application Server 3.1 Servlet 3.0//​EN"​ 
 +  ​"​http://​glassfish.org/​dtds/​glassfish-web-app_3_0-1.dtd">​
 <​glassfish-web-app>​ <​glassfish-web-app>​
 +    ...
     <​parameter-encoding default-charset="​UTF-8"​ />     <​parameter-encoding default-charset="​UTF-8"​ />
 +    ...
 </​glassfish-web-app>​ </​glassfish-web-app>​
 </​sxh>​ </​sxh>​
  
 https://​wikis.oracle.com/​display/​GlassFish/​FaqHttpRequestParameterEncoding https://​wikis.oracle.com/​display/​GlassFish/​FaqHttpRequestParameterEncoding
glassfish_uri_parameter_encoding.txt · Last modified: 2014/03/06 08:47 by mihael