servlet返回html给客户端:
package com.king;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("MyServlet doGet -------");
// resp.getWriter().println("Hello "+new java.util.Date().toString());
PrintWriter out = resp.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<h1>Hello Servlet Html </h1>");
out.println("</head>");
out.println("</html>");
}
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
doGet(req, resp);
}
}