a little bit of tech, a little bit of green, to help tame the savage techmachine.

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet
{
 public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
  {
   res.setContentType("text/html");
   PrintWriter pw=res.getWriter();
   pw.println("<html>");
   pw.println();
   pw.println("<body bgcolor=#3e3e3e>");
   pw.println();
   pw.println("<h1>Hello World! </h1>");
   pw.println();
   pw.println("</body></html>");
   pw.println();
   pw.close();
  }

 public HelloWorld() {}

}

存为HelloWorld.java, 因为我的机器上是同时装了Apache和Resin配合工作的,把HelloWorld.java放入
%APACHE%/htdocs/WEB-INF/classes目录下。

最后,http://localhost/servlet/HelloWorld就可以看到结果了。

posted on 2004-10-01 16:27  xyublog  阅读(632)  评论(0编辑  收藏  举报