logservlet.java
来自「21天学通java的示例程序源代码」· Java 代码 · 共 44 行
JAVA
44 行
import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;/** * This servlet demonstrates how to write to the servlet log. * Every method in this servlet writes to the servlet log. */public class LogServlet extends HttpServlet { public void init() throws ServletException { getServletContext().log("LogServlet: in the init() method"); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { getServletContext().log("LogServlet: in the doGet() method"); // create an exception and send it to the log Throwable throwable = new RuntimeException("An example exception"); getServletContext().log("Here's what an exception looks like", throwable); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { getServletContext().log("LogServlet: in the doPost() method"); } public void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { getServletContext().log("LogServlet: in the doPut() method"); } public void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { getServletContext().log("LogServlet: in the doDelete() method"); } public void destroy() { getServletContext().log("LogServlet: in the destroy() method"); } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?