arabic text from linux to windows oc4j servers
Date: 17 Aug 2004 23:52:24 -0700
Message-ID: <2a1d9770.0408172252.78c23f27_at_posting.google.com>
Hello,
[Quoted] I am trying to send arabic text from one oc4j 9i Release 2 j2ee server to a servlet in an another application server, through a URLConnection. i have set the encoding of the url connection to windows-1256. The characterset of the jsp is windows 1256. I have set the request from the jsp by calling
request.setCharacterEncoding("windows-1256") in the servlet. If the two oc4j are installed on windows machines, everything goes smooth, however, in my case, i have the servlet on a windows machine, while the jsp is calling it from a linux machine, in such case, I get ??????? instead of arabic characters.
The jsp code that calles the servlet is:
<%_at_ page contentType="text/html;charset=windows-1256"%>
<%_at_page import="java.io.*" import="java.net.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1256">
<title>
Hello World
</title>
</head>
<body>
<%
try{
String l_szIsTagged = "false";
URL l_URL = new URL("http://windowsserver:8888/SpeechServlet");
URLConnection l_URLConnection = l_URL.openConnection();
l_URLConnection.setDoOutput(true); l_URLConnection.setDoInput(true); l_URLConnection.setUseCaches(false); l_URLConnection.setRequestProperty("Method", "POST");
PrintWriter l_PrintWriter = new
PrintWriter(l_URLConnection.getOutputStream());
String l_szParams = "isTagged=false" + "&fileName=anything" +
"&arabicText=" + URLEncoder.encode("arabic text goes here...");
l_PrintWriter.println(l_szParams);
l_PrintWriter.close();
BufferedReader l_BufferedReader = new BufferedReader(new
InputStreamReader(l_URLConnection.getInputStream()));
String l_szResponseLine = "";
String l_szURLResponse;
for(l_szURLResponse = ""; (l_szResponseLine =
l_BufferedReader.readLine()) != null; l_szURLResponse = l_szURLResponse + l_szResponseLine); l_BufferedReader.close();
System.out.println(l_szURLResponse);
}
catch (java.net.MalformedURLException l_URLException) {
System.out.println(">>>>>>>>>>>>>>>>>>>>" +l_URLException.getMessage());
}
catch (java.io.IOException l_IOException)
{
System.out.println(">>>>>>>>><<<<<<<>>>>>>>>>>>"+l_IOException.getMessage());
}
%>
</body>
</html>
and the servlet code, in another server is:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*; import java.util.*; import java.util.Calendar; import java.sql.*;
public class SpeechServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=windows-1256";
public void init(ServletConfig config) throws ServletException {
super.init(config);
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("windows-1256"); response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
String arabicText = request.getParameter("arabicText");
System.out.println("arabic Text: " + arabicText);
out.println("<html>"); out.println("<head><title>SpeakServlet</title>"); out.println("<meta http-equiv='Content-Type' content='text/html;charset=windows-1256'></head>");
out.println("<body>"); out.println("arabic Text: " + arabicText); out.println("</body></html>"); out.close();
}
}
can someone help please? Received on Wed Aug 18 2004 - 08:52:24 CEST