WEB开发网
开发学院WEB开发Jsp Java核心代码例程之:Servlet----SimpleServl... 阅读

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
  {
  }
  **/
}

Tags:Java 核心 代码

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接