⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 message.jsp

📁 这个是使用JAVA+JSP编写的聊天室源码
💻 JSP
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.io.*" import="java.util.*" 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">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> 
<META HTTP-EQUIV="Expires" CONTENT="0"> 

<title>无标题文档</title>
</head>

<body>
<p>
<% 
response.setHeader("Pragma","No-cache"); 
response.setHeader("Cache-Control","no-cache"); 
response.setDateHeader("Expires", 0); 
%> 

<% 
   String all="";
   String s=this.getClass().getResource("txtfile.txt").getPath();
    String name=request.getParameter("name");
    String content=request.getParameter("content");
   for(int i=0;i<s.length()-2;i++){
       if(s.substring(i,i+3).equals("%20")){
          s=s.substring(0,i)+" "+s.substring(i+3);
            }
        }
  String submit=request.getParameter("Submit");
 if(submit!=null&&!submit.equals("")&&name!=null&&content!=null)
  {   Date ti = new Date();
      GregorianCalendar calendar = new GregorianCalendar();

      calendar.setTime(ti);
      int t1 = calendar.get(calendar.HOUR);
      int t2 = calendar.get(calendar.MINUTE);
      int t3 = calendar.get(calendar.SECOND); 
    
   
	if(name==null||content==null||name.equals("")||content.equals(""))
	   {
	   }
   else	{ all="<font color=8080ff>"+ti+":"+t2+":"+t3+"</font>.<font color=ff8080>"+name+"</font>: "+content+"<br>";
    
		INIFileIO ms1=new INIFileIO(s,false);
		String str=ms1.read();
		if(str==null) {str="";}
		all=str+all;
		INIFileIO ms=new INIFileIO(s,true);
        ms.write(all);
		all=null; 
		name=null;
		content=null;
		}
	  	submit=null;
   }
      INIFileIO ms2=new INIFileIO(s,false);
	  String str2= ms2.read();
	  if(str2==null){str2="";}
      out.print(str2);
	  name=null;
	  content=null;
%>
</p>
<form name="form1" method="post" action="">
  昵称:
    <input name="name" type="text" size="10" maxlength="15">
留言:
<input name="content" type="text" size="40">
<input type="submit" name="Submit" value="提交">
</form>
<p>&nbsp;</p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -