我使用JSP页面写入文件 JSP中的输入框将发送一些DATA
数据
FARSI(波斯语):INPUT_MSG =کدمنکارنمیکندبرایزبانفارسی。
<notification><myprojectid>256333859</myprojectid><mobile>123456789</mobile><uniqueid>ABCDEF565667DD</uniqueid><noation/><title>Push-Notification</title><message>INPUT_MSG</message><timestamp>20132611112245</timestamp></notification>
但是在文件中它已经存储在给定的值
中
éï ÃÂ
àéçñ ÃÂÃÂ
à éÃÂï èñçà òèçàÃÂçñóÃ.
JSP PAGE编码:SendMessage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<body>
<form method="post" action="genMsgFile.jsp" name="testForm">
<span>Farsi Message : </span>
<input type="text" name="faMSg" />
<input type="submit" value="Push Message" />
</form>
</body>
</html>
JSP PAGE编码:writeInfile.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="java.lang.*"%>
<html>
<body>
<%!
public void createFile(String msgLocation, String filepath, String msgTosend){
String fp = msgLocation + filepath;
// System.out.println("$$ PATH $$$ "+ fp);
try {
PrintWriter pw = new PrintWriter(new FileOutputStream(fp));
pw.println(msgTosend);
pw.close();
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
%>
<%
String farMsg = request.getParameter("faMSg");
createFile(msgPATH,farsiFile,farMsg);
%>
</body>
</html>
我应该在
writeInfile.jsp
中做出哪些更改,以便以可读格式存储???