liuyan1.jsp
<%
String temp=new String();
temp=(String)application.getAttribute("num");
if(temp==null){
application.setAttribute("num","0");
}
%>
<html>
<head>
<title>留言板</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
</head><body bgcolor="#FFFFFF" text="#000000">
<p>&nbsp;</p>
<p align="center"><b><font size="5" color="#FF6633">留 言 板</font></b></p>
<hr size="1">
<form name="form1" method="post" action="liuyan2.jsp">
  <table width="60%" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="#999999">
    <tr bgcolor="#FFFFFF"> 
      <td width="20%">留言作者:</td>
      <td width="80%"> 
        <input type="text" name="txtaut">
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="20%">留言标题:</td>
      <td width="80%"> 
        <input type="text" name="txttit">
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="20%">留言内容:</td>
      <td width="80%">&nbsp;</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="20%">&nbsp;</td>
      <td width="80%"> 
        <textarea name="txtart" cols="45" rows="7"></textarea>
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="20%">&nbsp;</td>
      <td width="80%">&nbsp;</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td colspan="2"> 
        <div align="center">
          <input type="submit" name="cmdok" value="添加到留言薄">
          <input type="reset" name="cmdreset" value="重新填写留言">
          <input type="button" name="cmdread" value="查看所有留言"
   onClick="MM_openBrWindow('liuyan3.jsp'),'','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width=400,height=400'">
        </div>
      </td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>
liuyan2.jsp
<html>
<head>
<title>留言板</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
</head><body bgcolor="#FFFFFF" text="#000000">
<p>&nbsp;</p>
<p align="center"><b><font size="5" color="#FF6633">留 言 板</font></b></p>
<hr size="1">
<%
int n;
String temp=new String();
String temp1=new String();
String temp2=new String();
String temp3=new String();
temp1=request.getParameter("txttit");
temp2=request.getParameter("txtaut");
temp3=request.getParameter("txtart");
n=temp1.length()*temp2.length()*temp3.length();
if(n!=0){
temp=(String)application.getAttribute("num");
n=Integer.parseInt(temp);
n=n+1;
temp=temp.valueOf(n);
application.setAttribute("num",temp);
application.setAttribute("tit"+temp,temp1);
application.setAttribute("aut"+temp,temp2);
application.setAttribute("art"+temp,temp3);
%>
<p>&nbsp;</p>
<p align="center">留言成功!</p>
<%
}
else{
%>
<p align="center"><font color="#FF0000">不添加作者、标题和内容,留言失败!</font></p>
<%
}
%>
<p align="center"><a href="liuyan1.jsp">返回首页</a> </p>
</body>
</html>
liuyan3.jsp
<html>
<head>
<title>留言板</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000">
<p>&nbsp;</p>
<p align="center"><b><font size="5" color="#FF6633">留 言 板</font></b></p>
<hr size="1">
<%
int n;
String temp=new String();
String temp1=new String();
String temp2=new String();
String temp3=new String();
temp=(String)application.getAttribute("num");
n=Integer.parseInt(temp);
if(n==0){
%>
<p>&nbsp;</p>
<p align="center">目前还没有文章!</p>
<%
}
else{
%>
<table width="60%" border="1" cellspacing="0" cellpadding="5" align="center" bordercolor="#999999">
  <%
  int i;
  for(i=1;i<=n;i++){
  temp=temp.valueOf(i);
  temp1=(String)application.getAttribute("tit"+temp);
  temp2=(String)application.getAttribute("aut"+temp);
  temp3=(String)application.getAttribute("art"+temp);
  %>
  <tr>
    <td bgcolor="#CCFFCC" height="27"><b><%=temp%>.标题:<%=temp1%>作者:<%=temp2%></b></td>
  </tr>
  <tr>
    <td><%=temp3%></td>
  </tr>
  <%
  }
  }
  %>
</table>
<p align="center">&nbsp;</p>
</body>
</html>