r kadam

Greenhorn
+ Follow
since Mar 12, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by r kadam

I am unable to retrieve form POST data in utf-8 and display it back in Browser Client. I have added this line in the HTML form:
<meta http-equiv="content-type" content="text/html; charset=utf-8">

In Servlet Code, I have specified the encoding:
// Retrieve the parameter data from Request
req.setCharacterEncoding("UTF8");
byte[] paramValue= req.getParameter("firstName").getBytes("UTF8");
String paramString = new String(paramValue);

This servlet works fine on my windows 2000 & weblogic8.1. But the same servlet sends back the actual input character On Solaris.

I have set following on solaris:
environment variable: LC_ALL=en_US.UTF-8
JVM argument : -Dfile.encoding=UTF-8

Thanks in advance.
19 years ago
I am trying to convert input parameter to UTF8 and then again get the original string from UTF8. This servlet works fine in Windows2000 but on solaris the converted value is not UTF8 but the original input parameter value. Is the code below the right way to convert the input string to UTF8 and to retrieve the original string back from UTF8.

Thanks in advance.
rk

Convert input String to UTF-8:

// set the character encoding to UTF-8
req.setCharacterEncoding("UTF8");

// retrieve the bytes for firstName parameter
byte[] pb1 = req.getParameter("firstName").getBytes("UTF8");

// store the UTF8 String
String pb1Str = new String(pb1);

System.out.println("UTF8 String:" + pb1Str);


Retrieve input String from UTF-8:

// get the bytes from UTF-8 String
byte[] pb2 = pb1Str.getBytes();

// Decode the String from UTF-8
String pb2Str = new String(pb2, "UTF8");

System.out.println("Original String:" + pb2Str);
20 years ago
I have a simple servlet which persists user entered text into database. The input data is converted to UTF-8 before it is persisted. During retrieval, I am not able to decode the UTF-8 string back to user input text. I am using browser to display the UTF-8 data assuming that browser (<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
) will be able to interpret the UTF-8 value.

Any help how to save and retrieve UTF-8 data will be appreciated. I am using weblogic 8.1, Oracle 9i release 2 and hibernate to persist & retrive the data. The servlet reading the servlet parameter and converts the incoming string to UTF8 using getBytes.

example string: ������
UTF-8 data stored in database: ������������

thanks
20 years ago