[서브렛 학습] 상속 Http서브렛의 간단한 예

3390 단어 servlet
 1 package com.sprying;
2 import java.io.IOException;
3 import java.io.PrintWriter;
4
5 import javax.servlet.http.HttpServlet;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpServletResponse;
8
9 /**
10 * servlet
11 * HttpServlet,
12 */
13 public class HttpExample extends HttpServlet
14 {
15 /**
16 *
17 */
18 private static final long serialVersionUID = 1L;
19 public void doGet(HttpServletRequest req,HttpServletResponse res)
20 {
21 this.doPost(req,res);
22 }
23 public void doPost(HttpServletRequest req,HttpServletResponse res)
24 {
25 try
26 {
27 PrintWriter pw=res.getWriter();
28 pw.print("HelloWorld,extends of HttpServlet");
29 }catch(IOException e)
30 {
31 e.printStackTrace();
32 }
33 }
34 }

좋은 웹페이지 즐겨찾기