package
import javax.servlet.*;
import javax.servlet.http.*;
import *;
public class HelloServlet extends HttpServlet {
//Initialize global variables
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=GB2312");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>CH2 - HelloServlet</title></head>");
out.println("<body>");
out.println(" Hello World <br>");
out.println("大家好");
out.println("</body>");
out.println("</html>");
out.close();
}
//Get Servlet information
public String getServletInfo() {
return " Information";
}
}
初学照着书上的方法运行的!还是不好用!