1 package com.ycw.newservlet;
2
3 import java.io.IOException;
4 import javax.servlet.ServletException;
5 import javax.servlet.annotation.WebServlet;
6 import javax.servlet.http.HttpServlet;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9
10 /**
11 * Servlet implementation class MyServlet
12 */
13 @WebServlet("/MyServlet")
14 public class MyServlet extends HttpServlet {
15 private static final long serialVersionUID = 1L;
16 @Override
17
18 public void init() throws ServletException {
19 // TODO 自动生成的方法存根
20 super.init();
21 }
22 /**
23 * @see HttpServlet#HttpServlet()
24 */
25 public MyServlet() {
26 super();
27 // TODO Auto-generated constructor stub
28 }
29
30 /**
31 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
32 */
33 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
34 // TODO Auto-generated method stub
35 response.getWriter().append("Served at: ").append(request.getContextPath());
36 }
37
38 /**
39 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
40 */
41 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
42 // TODO Auto-generated method stub
43 doGet(request, response);
44 }
45
46 }