• Post Reply Bookmark Topic Watch Topic
  • New Topic

saving chinese data to text file  RSS feed

 
sksharma sharma
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am sending some "chinese" data through form post from jsp file to some servlet.
This as fine I an sending proper UTF8 enconing formant.

But my problem is in the servlet how can I fetch this form data and save it to text file on my file system.
when I am saving it to file system it is saved as some junk characters.

this is the jsp file I am using for sending data.


<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="java.net.URLEncoder" %>

<HTML>

<HEAD>
<TITLE>My Interface</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=TH">
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<meta http-equiv="Content-Type" content="text/html; charset=window-874">
</HEAD>
<BODY>

<form action="my servlet adress." method="post" >

<INPUT type="text" name="rword" maxlength="60">
<INPUT type="Submit" VALUE="Submit">


</form>
</BODY>
</HTML>


can u please help me how to fetch this chinese charater in servlet and save to text file so that it will look in proper format.

looking for ur response

Thanks and regards
sunil
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Several things come to mind that you could investigate. First, since you specify the content type using JSP, remove the various HTML meta tags. I can easily see that confusing the browser. Secondly, do you set the content type of the response before retrieving anything from it? That is to say, after getting values from the response and before writing them to disk, are they OK? Lastly, are you using the proper encoding when writing the values to a file? If you specify no encoding, the default one is used, and that is not UTF-8.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!