package com.sprying;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*第三种方法开发servlet
*通过继承HttpServlet,
*/
public class HttpExample extends HttpServlet
{
/**
*
*/
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest req,HttpServletResponse res)
{
this.doPost(req,res);
}
public void doPost(HttpServletRequest req,HttpServletResponse res)
{
try
{
PrintWriter pw=res.getWriter();
pw.print("HelloWorld,extends of HttpServlet");
}catch(IOException e)
{
e.printStackTrace();
}
}
}