/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.myserv;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
*
* @author dell
*/
public class bottom extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("gb2312");
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head>");
out.println("<meta http-equiv=\"refresh\" >");
out.println("</head>");
out.println("<body>");
HttpSession session = request.getSession();
String name = (String) session.getAttribute("userName");
String toname = request.getParameter("toname");
out.println("<form id=\"form2\" name=\"form2\" method=\"post\" action=\"bottom\" target=\"bottomFrame\">");
String peoples = (String) getServletContext().getAttribute("peoples");
String people[] = peoples.split(",");
if(peoples!=null)
{
peoples = peoples + "," + toname;
getServletContext().setAttribute("peoples", peoples);
}
out.println("</form>");
out.println("<form id=\"form2\" name=\"form2\" method=\"post\" action=\"middle\" target=\"middleFrame\">");
out.println("对");
out.println("<select name= \"toname\" >");
for (int i = 0; i < people.length; i++) {
if (i == 0) {
out.println("<option value=\"" + people[i] + "\" selected>" + people[i] + "</option>");
} // out.println("<option value=fan selected>"+people[i]+"</option>");
else {
out.println("<option value=\"" + people[i] + "\">" + people[i] + "</option>");
}
// out.println("<option value=star>"+people[i]+"</option>");
}
out.println("</select>");
out.println("说:");
out.println("<label>");
out.println("<input type=\"text\" name=\"word\">");
out.print("</label>");
out.println("<input type=\"submit\" name=\"Submit\" value=\"提交\">");
out.println("</form>");
out.println("<form id=\"form3\" name=\"form3\" method=\"post\" action=\"bottom\" target=\"bottomFrame\">");
out.println("<input type=\"submit\" name=\"Submit1\" value=\"刷新\">");
out.println("</form>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
没有合适的资源?快使用搜索试试~ 我知道了~
利用servlet实现一个简单的聊天室
共42个文件
html:11个
xml:10个
java:4个
5星 · 超过95%的资源 需积分: 26 216 下载量 197 浏览量
2011-12-22
10:22:35
上传
评论 5
收藏 1.52MB ZIP 举报
温馨提示
利用servlet技术实现一个简单的聊天室,实现多人同时交流。当发送聊天信息时,信息窗口刷新。信息窗口显示发言人的姓名以及发言的内容。在进入聊天室之前需要进行登录,即输入用户名。
资源推荐
资源详情
资源评论
收起资源包目录
聊天室.zip (42个子文件)
聊天室
liaotianshi
build_1.xml 3KB
test
build.xml 3KB
src
conf
MANIFEST.MF 25B
java
com
myserv
login.java 3KB
bottom.java 4KB
middle.java 4KB
nbproject
build-impl.xml 46KB
private
private.xml 211B
private.properties 3KB
ant-deploy.xml 4KB
project.xml 691B
genfiles.properties 473B
project.properties 2KB
web
middle.html 357B
WEB-INF
web.xml 1KB
sun-web.xml 512B
Main.html 737B
login.html 1KB
11.jpg 760KB
index.jsp 463B
bottom.html 703B
top.html 481B
build
empty
generated
src
org
apache
jsp
index_jsp.java 3KB
index_jsp.class.smap 72B
classes
org
apache
jsp
index_jsp.class 3KB
web
gfv3ee6.dpf 512B
META-INF
MANIFEST.MF 25B
middle.html 357B
WEB-INF
web.xml 1KB
classes
.netbeans_automatic_build 0B
.netbeans_update_resources 0B
com
myserv
login.class 2KB
middle.class 3KB
bottom.class 3KB
sun-web.xml 512B
Main.html 737B
login.html 1KB
11.jpg 760KB
index.jsp 463B
1.html 377B
bottom.html 703B
top.html 481B
共 42 条
- 1
fanfangogo90
- 粉丝: 2
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页