Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

saving chinese data to text file  RSS feed

sksharma sharma
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="" %>
<%@ page import="" %>


<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">

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

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


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
Ulf Dittmer
Posts: 42972
  • 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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!