一个简单聊天室程序,为什么输入的中文老是乱码呢,该加的都加啦,救
cds1 2006-08-08 10:02:11 <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>聊天室</title>
</head>
<body>
一个简单的聊天室
<br><hr><font color=red>
<%
response.setContentType("text/html;charset=GBK");
request.setCharacterEncoding("GBK");
String content=(String)getServletContext().getAttribute(new String("chatTopic_1"));
out.println(content);
getServletContext().setAttribute("chatTopic_1",content+(String)request.getParameter("content")+"<br>");
%>
</font>
<hr>
<form action="ServletContext_chast.jsp">
<input type=text name=content>
<input type=submit value="说话呀">
</form>
</body>
</html>
输出部分内容如下:
一个简单的聊天室
--------------------------------------------------------------------------------
nullnull
??????°?°?
pi
???è??
???è??
????
????????
null
×???
??
heoo
fsla
fdsfa
fdsfa
°é×???
??
??