chatroom.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'MyJsp.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->  </head>
  
  <body>
  
     <table width="100%">
       <tr>
         <td>1<iframe id="contentFrame"
         src="content.jsp" tyle="width:100%;height:100%">
         </iframe></td>
       </tr><tr>
         <td height="100%"><form name="f1" method="post" action="talk.jsp">
              发言<input type="text" name="textTalk">
         <input type="submit" value="提交">
         </form>
         </td>
       </tr>
      </table>
  
  </body>
</html>talk.jsp
<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="ISO-8859-1"%>
<!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=GBK">
<title>Insert title here</title>
 <script>
 function refresh(){
 window.location=window.location;
 }setTimeout("refresh()",5000)
 </script>
</head>
<body>
<%String userName=(String)session.getAttribute("userName");
String content=(String)application.getAttribute("Content");
if(content==null)content=&quot;;
out.println(content);
 %>
</body>
</html>
content.jsp
<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="gbk"%>
<!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=GBK">
<title>Insert title here</title>
</head>
<body>
<%String userName=(String)session.getAttribute("username");
String oldContent =(String)application.getAttribute("content");
if(oldContent==null)oldContent="";
oldContent+=Content+"("+new Date()+")"+"<br>";
application.setAttribute("content".oldContent);
response.sendRedirect("chatroom.jsp");
 %>
</body>
</html>