Hi,
In an attempt to solve a problem of getting a request in a non English
character, and to convert it to Unicode,
I use a similar code , (BTW , taken from O'Reilly's "Java Servlet
programing" First edition)


import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class MyServlet extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
try {
//set encoding of request and responce
req.setCharacterEncoding("Cp1255"); //for hebrew windows 
res.setCharacterEncoding("Cp1255");
res.setContentType("Text/html; Cp1255");
String value = req.getParameter("param");

// Now convert it from an array of bytes to an array of characters.
// Here we bother to read only the first line.
BufferedReader reader = new BufferedReader(
new InputStreamReader(new StringBufferInputStream(value), "Cp1255"));
String valueInUnicode = reader.readLine();
}catch (Exception e) {
e.printStackTrace();
}
}
}


this works fine , the only problem is that StringBufferInputStream is
deprecated .
is there any other alternative for that ?
Thanks in advance 
Yair 
 
 
Yair Fine
Golden-Channels
03 9272791
052 921250
 

Reply via email to