|
| Problem | The use of non-ASCII characters in HTTP Cookies, or any other HTTP header, is not permitted. However, there are other ways to address the issue. | | | | Solution | According to RFC 2109 and 2068, only ASCII characters having values from 32 to 127 are permitted within HTTP headers; which includes HTTP Cookies. Therefore placing DBCS and other non-ASCII characters inside of cookies is not permitted. However, there is a programmatic solution to this problem: Encoding. The following is an example of how this may be accomplished.
public void handleDBCSCharacters (String header, String value, HttpServletResponse response){ byte b[]; try { b = value.getBytes(response.getCharacterEncoding()); } catch (Exception ex) { b = value.getBytes(); } char c[] = new char[b.length]; for (int i=0;i<b.length;i++) c[i]=(char)(((char)b[i])&0xff); response.setHeader(header,new String(c)); }
Please note that this code is NOT supported by WebSphere, or IBM. It is placed here only as an example of how such encoding might be accomplished, and to provide ideas for your own program development. | |
| | |
| |
|
Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, Double Byte Character Set (DBCS) Operating system(s): Multi-Platform Software version: 3.5, 4.0, 5.0, 5.1, 6.0 Software edition: Edition Independent Reference #: 1078584 IBM Group: Software Group Modified date: 2003-11-04
(C) Copyright IBM Corporation 2000, 2004. All Rights Reserved.
|