Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Farsi in JSP

  Asked By: Daisy    Date: Jan 18    Category: Java    Views: 1776

I've a problem and if u please help me.
My system configuration is :
Windows 2000 Professional
Allaire Jrun 3
Sun JDK 1.3.1
Microsoft Access 2000

this is my code:

<%@page contentType="text/html; charset=Cp1256" language="java" import="java.sql.*"%>
Driver driverUser = (Driver)Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection connConnection = DriverManager.getConnection("jdbc:odbc:MSAccessDB","","");
String stmSQL = "SELECT FirstName FROM Header";
PreparedStatement pstmStatementUser = connConnection.prepareStatement(stmSQL);
ResultSet rsResultSet = pstmStatementUser.executeQuery();
String varTestFarsi = new String(rsResultSet.getString("FirstName").getBytes(),"Cp1256");
<td><%= varTestFarsi %></td>

When I run this page, I just see some Question Marks (?) insteas of the correct characters(the field filled with persian characters).I test this page with utf-8 and wimdows-1256 but nothing happens.
I change Sun JDK to IBM JDK and JRun to Tomcat 4, and test my page again, but still there are question marks.
The Default encoding of installed JVM is Cp1252, I change it to utf-8 and windows-1256, nothing happens....

I don't know what's my problem, please HELP...



1 Answer Found

Answer #1    Answered By: Steve Boyd     Answered On: Jan 18

I assume that you are sure that cp1256 is capable of displaying all
needed characters.
Then I would suggest to check the following:
Depends on what version of Windows you are on. Farsi is not officially
supported in all code points for cp1256 ;( (check UNICODE website as
well as some websites specialized on Farsi)

Make sure you have all this three lines in your JSP page (in the same
order, where the META tag has to be within the HTML <HEAD> section):
<% response.setContentType("text/html; charset=cp1256"); %>
<%@ page content="text/html;charset=cp1256"%>
<meta http-equiv="Content-Type" content="text/html; charset=cp1256">

What is the content page setting of your DB? CP1256?? UTF8? Win1256?
I would assume that the problem  is how MSAccess handles Farsi.

Didn't find what you were looking for? Find more on Farsi in JSP Or get search suggestion and latest updates.