日期:2014-05-18 浏览次数:20739 次
import java.io.*;A. 一个HTML页面,页面上显示doGet Hello World!
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet{
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException{
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("");
out.println("");
out.println("doGet Hello World!");
out.println("");
out.println("");
out.close();
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("");
out.println("");
out.println("doPost Hello World!");
out.println("");
}
}