动态生成HTML文档

UseServlet.java

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.*;

public class UseServlet extends HttpServlet{

    private static final long serialVersionUID = 1L;
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        //设置字符集格式为utf-8
        resp.setCharacterEncoding("UTF-8");
        //设置响应正文的MIME类型
        resp.setContentType("text/html");
        PrintWriter out = resp.getWriter();
        out.println("");
        out.println("动态生成HTML文档");
        out.println("");
        out.println("");
        out.println("");
        out.println("
动态生成HTML文档
"); out.println(""); out.flush(); out.close(); } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub doPost(req, resp); } }

web.xml

  
    UseServlet
    com.use.UseServlet
  
  
    UseServlet
    /html
  
  
11.PNG

你可能感兴趣的:(动态生成HTML文档)