1.JSP文件
function ajaxReq(){
var url = "ChatRoomServlet";
var param = "fname=${param.fname}&tname=${param.tname}";
new Ajax.Request(url,{
?method:"get",
?parameters:encodeURI(param),
?requestHeaders:['Cache-Control','no-cache','If-Modified-Since','0'],
??? onSuccess:function(httpObj){
??? ?$("chatarea").value = httpObj.responseText;
??? },
??? onFailure:function(httpObj){
??? }
});
?
2.servlet的doGet方法:
?
String fname = request.getParameter("fname");
fname = new String(fname.getBytes("ISO-8859-1"),"UTF-8");
?
?