Akdora’s Blog

Programming, Oracle, Life, Fun

Turkish Character Problem (Türkçe Karakter Problemi) February 23, 2009

When we write jsp pages, we add the following code to the page to encode the characters in desired charset.

<%@ page contentType="text/html;charset=iso-8859-9"%>

Although to add this code, we sometimes face up the character problem.  Expecially, if we change the mimeType of the page. I mean, export the page as excel.

(If you want to export any data in a excel file from jsp, change the mimetpye of the jsp and write your data in table tags)

if (pageType != null && pageType.equalsIgnoreCase("excel")) {
   String mimeType = "application/vnd.ms-excel;charset=ISO-8859-9";
   response.setContentType(mimeType);
   String filename = "MyExcelFile";
   response.setHeader("Content-Disposition","attachment;filename=" + filename + ".xls");
   //System.out.println(response.getCharacterEncoding());
}

When you get this problem, try to add the following code in the HEAD tag of the page. It will fixed up.

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">

 I searched this simple code for a long time:), because it think that the first code enough to encode the charset. But it is not.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s