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;
//扩展 HttpServlet实现Servlet程序
public class Demo13 extends HttpServlet {
//如果浏览器是以get方式提交,则覆写doGet()方法
public void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter pw = response.getWriter();
pw.write("<ol>");
pw.write("<li>JavaServlet</li>");
pw.write("<li>JavaJsp</li>");
pw.write("<li>JavaStruts</li>");
pw.write("</ol>");
}
}
配置:
web.xml
结果:
扩展 HttpServlet实现Servlet程序 学习笔记
原文地址:http://blog.51cto.com/357712148/2104366