Try specifying the encoding in your client as as "windows-1255" Mark
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Sunday, April 25, 2004 6:28 PM > To: [EMAIL PROTECTED] > Subject: RE: Getting a request in a non English character > > Mark, > Your client and servlet works!! Thanks. > Now I have only one request, > I tried to modify the client, that instead of preparing a > predefined line: > String data = "name=" + URLEncoder.encode("\u05d9\u05d0\u05d9\u05e8", > "cp1255"); > The client will read a file that is written in a windows > -1255 encoding > > BufferedReader bri = new BufferedReader(new > InputStreamReader(new > FileInputStream("request"),"Cp1255")); > String line = bri.readLine(); // > read just one line from hebrew request text > String data = URLEncoder.encode(line, "cp1255"); > > And this some how doesn't work , > Any suggestions? > Regard > Yair > > > -----Original Message----- > From: Mark Thomas [mailto:[EMAIL PROTECTED] > Sent: Sunday, April 25, 2004 5:09 PM > To: 'Tomcat Users List' > Subject: RE: Getting a request in a non English character > > Got this working. Mainly just the issue of the encoding that > was being used > for > the response from the servlet. You need to be careful with > the names of the > encoding as they can differ between operating systems. My > recommendation > would > be to always use UTF-8. My version of your servlet and client > are below. > > Hope this helps > > Mark > > > SERVLET > ======= > package test.encoding; > > import java.io.IOException; > import java.io.PrintWriter; > > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > public class Echo extends HttpServlet { > > public Echo() { > super(); > } > > public void doGet(HttpServletRequest request, HttpServletResponse > response) > throws ServletException, IOException { > > doPost(request, response); > } > > public void doPost( > HttpServletRequest request, > HttpServletResponse response) > throws ServletException, IOException { > > request.setCharacterEncoding("cp1255"); > > response.setContentType("text/html; charset=windows-1255"); > > PrintWriter out = response.getWriter(); > String name = request.getParameter("name"); > out.println(name); > } > > } > > CLIENT > ====== > package test.encoding; > > import java.io.BufferedReader; > import java.io.File; > import java.io.FileWriter; > import java.io.InputStream; > import java.io.InputStreamReader; > import java.io.OutputStream; > import java.net.URL; > import java.net.URLConnection; > import java.net.URLEncoder; > > public class Client { > > public static void main(String[] args) { > try { > String host = "localhost"; > String port = "8080"; > > // the unicode for "Yair" in hebrew. > String data = "name=" + > URLEncoder.encode("\u05d9\u05d0\u05d9\u05e8", "cp1255"); > // URL test = new > URL("http://"+host+":"+port+"/Bugfix/encoding/bug14742Output.jsp"); > URL test = new > URL("http://"+host+":"+port+"/Bugfix/servlet/Echo"); > URLConnection req = test.openConnection(); > req.setDoOutput(true); > req.setRequestProperty("Content-Type", > "application/x-www-form-urlencoded; charset=windows-1255"); > req.setRequestProperty("Content-Length", > Integer.toString(data.length())); > OutputStream out = req.getOutputStream(); > // writing the request in Cp1255 encoding. > out.write(data.getBytes("cp1255")); > out.close(); > > InputStream in = req.getInputStream(); > // reading the response in Cp1255 encoding. > BufferedReader br = new BufferedReader(new > InputStreamReader(in)); > // instead of getting my name in hebrew . I get > "????" four > times > 0xF9 in the text file in.txt > File f = new File("in.txt"); > FileWriter fw = new FileWriter(f); > int code; > while ((code = br.read()) != -1) { > System.out.println(code); > fw.write(code); > } > fw.close(); > } catch (Exception e) { > e.printStackTrace(); > } > > } > } > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]