JSP简易聊天室

这是一个网页版的简易聊天室,做的界面是不是很好 请见谅^_^

<%@ page language="java" contentType="text/html; charset=gbk"
    pageEncoding="gbk"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title heretitle>
head>
<body>
<form method = "post" action = "chuli.jsp">
用户名:<input type = "text" name = "user">input><br>
密码:<input type = "password" name = "pass">input><br>
<input type="submit" value ="登录">input>
form>
body>
html>
<%@ page language="java" contentType="text/html; charset=gbk"
    pageEncoding="gbk"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title heretitle>
head>
<body>
<%
  String us="", ps="";
  us = request.getParameter("user");
  ps = request.getParameter("pass");
  if(ps.equals("123456")){
      session.setAttribute("sess_us", us);
      response.sendRedirect("chat.jsp");
  }
  else{
      out.print("对不起 您的密码不正确");
  }
%>
body>
html>
<%@ page language="java" contentType="text/html; charset=gbk"
    pageEncoding="gbk" import="java.util.*"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title heretitle>
<script type="text/javascript">
  function Judge(){
    var s;
    s = chats.say.value;
    if(s==""){
        alert("发言不能为空");
        return false;
    }
    return true;
  }
 script>
head>
<body>
<%
  response.setHeader("refresh","5");
  String sess_us, fy, tmp;
  request.setCharacterEncoding("gbk");
  sess_us = (String)session.getAttribute("sess_us");
  Date now = new Date();
  fy = request.getParameter("say");
  if(fy != ""){
    String ans = now.toString()+"   "+sess_us+"说: "+fy+"
"
; if(application.getAttribute("app_fy")== ""){ application.setAttribute("app_fy", ans); } else{ tmp = (String)application.getAttribute("app_fy"); ans = tmp + ans; application.setAttribute("app_fy", ans); } } %>
<table border="1" width="800"> <tr><td><%=application.getAttribute("app_fy") %> table> <form action="chat.jsp" method = "post" name = "chats"> <textarea rows="3" cols="80" name = "say">textarea><br> <input type = "submit" value = "发言" onclick = "return Judge()">input> form> body> html>

你可能感兴趣的:(HTML,ITAK的ACM之路,计算机专业的相关课程知识)