doHeader 用于处理HEADER请求
doGet 用于处理GET请求,也可以自动的支持HEADER请求
doPost 用于处理POST请求
doPut 用于处理PUT请求
doDelete 用于处理DELETE请求

1 package org.caiduping.Servlet;
2
3 import java.io.IOException;
4 import java.io.PrintWriter;
5
6 import javax.servlet.ServletException;
7 import javax.servlet.http.HttpServlet;
8 import javax.servlet.http.HttpServletRequest;
9 import javax.servlet.http.HttpServletResponse;
10
11 public class Servlet extends HttpServlet {
12
13 /**
14 * Constructor of the object.
15 */
16 public Servlet() {
17 super();
18 }
19
20 /**
21 * Destruction of the servlet. <br>
22 */
23 public void destroy() {
24 super.destroy(); // Just puts "destroy" string in log
25 // Put your code here
26 }
27
28 /**
29 * The doGet method of the servlet. <br>
30 *
31 * This method is called when a form has its tag value method equals to get.
32 *
33 * @param request the request send by the client to the server
34 * @param response the response send by the server to the client
35 * @throws ServletException if an error occurred
36 * @throws IOException if an error occurred
37 */
38 public void doGet(HttpServletRequest request, HttpServletResponse response)
39 throws ServletException, IOException {
40
41 response.setContentType("text/html");
42 PrintWriter out = response.getWriter();
43 out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
44 out.println("<HTML>");
45 out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
46 out.println(" <BODY>");
47 out.print(" This is ");
48 out.print(this.getClass());
49 out.println(", using the GET method");
50 out.println(" </BODY>");
51 out.println("</HTML>");
52 out.flush();
53 out.close();
54 }
55
56 /**
57 * The doPost method of the servlet. <br>
58 *
59 * This method is called when a form has its tag value method equals to post.
60 *
61 * @param request the request send by the client to the server
62 * @param response the response send by the server to the client
63 * @throws ServletException if an error occurred
64 * @throws IOException if an error occurred
65 */
66 public void doPost(HttpServletRequest request, HttpServletResponse response)
67 throws ServletException, IOException {
68
69 response.setContentType("text/html");
70 PrintWriter out = response.getWriter();
71 out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
72 out.println("<HTML>");
73 out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
74 out.println(" <BODY>");
75 out.print(" This is ");
76 out.print(this.getClass());
77 out.println(", using the POST method");
78 out.println(" </BODY>");
79 out.println("</HTML>");
80 out.flush();
81 out.close();
82 }
83
84 /**
85 * Initialization of the servlet. <br>
86 *
87 * @throws ServletException if an error occurs
88 */
89 public void init() throws ServletException {
90 // Put your code here
91 }
92
93 }

  

最新文章

  1. SqlCommand执行带GO的SQL脚本文件
  2. oc获得相册照片
  3. python os.system()返回值判断
  4. Power Gating的设计(概述)
  5. poj3525Most Distant Point from the Sea(半平面交)
  6. HDU 4351 Digital root 线段树区间合并
  7. Hibernate从入门到精通(四)基本映射
  8. mkimage使用详解
  9. 【C语言探索之旅】 第二部分第八课:动态分配
  10. MSBuild Tools解决办法
  11. python 中 reduce 函数的使用
  12. c# error
  13. c/c++ 继承与多态 文本查询的小例子(智能指针版本)
  14. javascript 之 数组
  15. 使用Microsoft自带的小工具将可执行文件(.exe)注册为系统服务
  16. C#.NET 中的 Timer 计时器及 3 种使用方法
  17. Python全栈学习_day004作业
  18. 把文本数据转化为json
  19. 开始转型学习java
  20. asp mvc @Html.CheckBox(&quot;sel&quot;,true) 往后台传值问题

热门文章

  1. myGeneration代码生成器
  2. 如何在Android中使用OpenCV
  3. 一个非常标准的Java连接Oracle数据库的示例代码
  4. hadoop namenode又一次格式化以后hbase的hmaster进程启动后立即消失
  5. PI-利用SoapUI 测试web service的方法介绍
  6. WPF自己定义命令Command
  7. utf-8 和gbk编码的差别
  8. cocos2d-x如何优化内存的应用
  9. MYSQL查询今天昨天本周本月等的数据
  10. Maven学习小结(七 生命周期[转])