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

Exporting 2 byte character data from jsp to excel  RSS feed

 
Suhana Nanda
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would request any help on the following.
How to export 2 BYTE character data that is displayed in a JSP to an Excel spreadsheet ?I am working on a multilingual application with Oracle as the back end. I want to export the data both in English and japnese. The code written below, displays the data in English(in excel),but in case of japnese , it shows junk characters.

<HTML>
<head>
</head>
<body >

<%String strData=request.getParameter("va"); // the variable va has the data (in html format) that I want to print in the excel in the html .

byte[] buffer1 = null;
strData = new String(strData.trim().getBytes("ISO_8859_1"), "Shift_JIS");
buffer1= strData.getBytes();
try{
response.setContentType("application/xls; charset=Shift-JIS");//set the content type

attached_filename="main.xls";

response.setHeader("Content-Disposition", "attachment;filename=" + attached_filename + ";size=" + buffer1.length + "");

out.clearBuffer();

PrintWriter pw =new PrintWriter(out);
pw.print(strData);
pw.flush();
pw.close();
}
catch(Exception e)
{}%>
</body>
</HTML>

Please suggest me a way out?

Sample code would be appreciated.Thanks in advance.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!