Customizing HTTP Error Responses Determining the Encoding of an HTTP Request

5-4 Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server

5.6 Customizing HTTP Error Responses

You can configure WebLogic Server to respond with your own custom Web pages or other HTTP resources when particular HTTP errors or Java exceptions occur, instead of responding with the standard WebLogic Server error response pages. You define custom error pages in the error-page element of the Java EE standard Web application deployment descriptor, web.xml. The web.xml file is located in the WEB-INF directory of your Web application.

5.7 Determining the Encoding of an HTTP Request

WebLogic Server converts binary bytes data contained in an HTTP request to the correct encoding expected by the servlet. The incoming post data might be encoded in a particular encoding that must be converted to the correct encoding on the server side for use in methods such as request.getParameter... There are two ways you can define the code set: ■ For a POST operation, you can set the encoding in the HTML form tag. For example, this form tag sets SJIS as the character set for the content: form action=http:some.host.commyWebAppfooindex.html input type=applicationx-www-form-urlencoded; charset=SJIS form When the form is read by WebLogic Server, it processes the data using the SJIS character set. ■ Because all Web clients do not transmit the information after the semicolon in the above example, you can set the code set to be used for requests by using the input-charset element in the WebLogic-specific deployment descriptor, weblogic.xml. The java-charset-name subelement defines the encoding used to convert data when the URL of the request contains the path specified with the resource-path subelement. This following example ensures that all request parameters that map to the pattern foo are encoded using the Java character set SJIS. input-charset resource-pathfooresource-path java-charset-nameSJISjava-charset-name input-charset This method works for both GET and POST operations.

5.8 Mapping IANA Character Sets to Java Character Sets