Oracle Application Server Containers for J2EE Support for JavaServer Pages API Reference
10g Release 2 (10.1.2)

B14015-02


oracle.jsp.util
Class PublicUtil

java.lang.Object
  extended byoracle.jsp.util.PublicUtil


public class PublicUtil
extends java.lang.Object

This class is a collection of static utility API methods, which are intended for public external usage


Constructor Summary
PublicUtil()

Method Summary
static void setReqCharacterEncoding(javax.servlet.http.HttpServletRequest req, java.lang.String encoding)
The emulation of "request.setCharacterEncoding(String encoding)" when using OracleJSP on Apache/JServ.
static void setWriterEncoding(javax.servlet.jsp.JspWriter out, java.lang.String encoding)
to set special char set (non-IANA charset, for example, "MS950") in JspWriter.

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

PublicUtil

public PublicUtil()

Method Detail

setReqCharacterEncoding

public static void setReqCharacterEncoding(javax.servlet.http.HttpServletRequest req,
                                           java.lang.String encoding)
                                    throws java.io.UnsupportedEncodingException
The emulation of "request.setCharacterEncoding(String encoding)" when using OracleJSP on Apache/JServ.

This API is intended to be used on OracleJSP on Apache/JServ only. When OC4J is used as the servlet engine, please make use of "request.setCharacterEncoding(String encoding)" directly, because OC4J is a servlet 2.3 compatible implementation.

Throws:
java.io.UnsupportedEncodingException

setWriterEncoding

public static void setWriterEncoding(javax.servlet.jsp.JspWriter out,
                                     java.lang.String encoding)
to set special char set (non-IANA charset, for example, "MS950") in JspWriter.

Background information:
Normally, JSP developers would set the character set of the JspWriter through:
(i) a page directive: e.g. <%@ page contentType="text/html;charset=xyz" %>
or (ii) response object API: e.g. response.setContentType("text/html;charset=xyz");
That means, the charset of the content type is the charset used in JspWriter. However, there are some some NLS character sets which are not IANA charset. That means, we cannot use those charset in content type directly. Because, most of browsers would just recognize non-IANA charset as their content type.

Hence, we have developed this special API to decouple the charset in contentType and the charset used in JspWriter. After using this API, the charset from the content type will be overrided by the charset given in this API parameter. e.g.:
<%@ page contentType="text/html;charset=Big-5" %>
<% oracle.jsp.util.PublicUtil.setWriterEncoding(out,"MS950"); %>
This example uses "Big-5" as the charset of the content type, while using "MS950" (a non-IANA HongKong dialect version of "Big-5" charset) as the charset of JspWriter.

NOTE: make this call as early as possible in the page.


Oracle Application Server Containers for J2EE Support for JavaServer Pages API Reference
10g Release 2 (10.1.2)

B14015-02


Copyright © 2004, 2005, Oracle. All rights reserved.