/*
* 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实现一个简单的聊天室
5星 · 超过95%的资源 需积分: 26 68 浏览量
2011-12-22
10:22:35
上传
评论 5
收藏 1.52MB ZIP 举报
fanfangogo90
- 粉丝: 2
- 资源: 8
最新资源
- 在matlab中通过yalmip平台调用cplex求解器,可用于求解MILP问题,适合于综合能源系统优化求解(注释完全,可直接运
- MT8852B labview 驱动,MT8852B labview 代码,蓝牙测试仪MT8852B代码,蓝牙低功耗测试
- 导照片2.0(只适合索尼微单)
- KMP算法python代码实现与使用场景.docx
- 基于MATLABCPLEX 的机组最优组合,成功求解表格化,图示化的机组组合结果(注释完全,可直接运行)(文档加Matlab源码
- postgresql-9.5.3-1-windows-x64
- 基于大数据和产业互联网的企业数字化转型.rar
- MySQL5与PHP5开发的相册系统源码.zip
- 支持linux CentOS安装 jdk1.8的jenkins
- Clover四叶草引导中文版
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页