Java核心代码例程之:Servlet----SimpleServlet.java
2008-01-05 08:38:16 来源:WEB开发网核心提示:import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class SimpleServlet extends HttpServlet{public void doGet(HttpServletRequest request,
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SimpleServlet
extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletOutputStream sos = response.getOutputStream();
sos.PRintln("<h1>doGet: Hello World!</h1>");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletOutputStream sos = response.getOutputStream();
sos.println("<h1>doPost: Hello World!</h1>");
}
/*
// Instead of calling doGet() or doPost(), service() can accomodate both
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
}
**/
}
更多精彩
赞助商链接