web.xml configuration:
jsp code:
Note : Action is doing the writing process like for this alias landing, way method is requested
Get request requesting entity no way
// If you just look at the effect of light on to write about the service method on the line Package Penalty for com.zyb.test; Import java.io.IOException; Import javax.servlet.ServletException; Import javax.servlet.http.HttpServlet; Import javax.servlet.http .HttpServletRequest; Import javax.servlet.http.HttpServletResponse; Import com.sun.java_cup.internal.runtime.Symbol; public class the TestServlet the extends the HttpServlet { @Override protected void-Service (the HttpServletRequest REQ, the HttpServletResponse RESP) throws ServletException, IOException { RESP. getWriter () write ( "test file ");. // printed page System.out.println ( "test file"); // print console } @Override public void the init () {throws ServletException System.out.println("Servlet初始化完成!"); } public void destory() { System.out.println("Servlet销毁完成!"); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("我是doPost方法!"); } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("我是doGet方法!"); } }
final effect: