用jsp代码编写的网络聊天室程序

2022-05-20 04:52:16   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《用jsp代码编写的网络聊天室程序》,欢迎阅读!
编写,聊天室,代码,程序,网络
<%@ page contentType="text/html;charset=GBK" import="java.util.*"%>

</word><word ps='' class=''>带自动刷新的简易聊天室</word><word ps='' class=''>

<% if (request.getProtocol().compareTo("HTTP/1.0") == 0) response.setHeader("Pragma", "no-cache"); else if (request.getProtocol().compareTo("HTTP/1.1") == 0) response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", -1); %>

当前时间: <%

response.setHeader("Refresh","30");

request.setCharacterEncoding("GBK");

Date d=new Date();

out.println(""+ d.toLocaleString());

String userName = (String)session.getAttribute("userName"); if (userName == null ) userName="Guest"; String chat = request.getParameter("mychat"); String chats = (String)application.getAttribute("chat"); if (chat!=null){ d=new Date(); chat=userName + "(" + d.toLocaleString() + "):" + chat; if (chats==null) chats=chat; else chats = chats + "
"
+ chat; }

if (chats!=null){ application.setAttribute("chat", chats); %>


border="2" width="400" bordercolorlight="#FFFFFF" bordercolordark="#000000" cellspacing="0" cellpadding="0">



简易聊天室
<%= application.getAttribute("chat")%>
<%}%>

ACTION="chat.jsp" METHOD="post"> //注意本表单提交给当前页面 action ALUE="我来了!"> ALUE="我说一句">



本文来源:https://www.wddqxz.cn/afadee2f15fc700abb68a98271fe910ef12dae94.html

相关推荐