public class TestOutHTML extends HttpServlet{

   private static ThreadLocal tLocal = null;
 
   @Override
   public void init() throws ServletException {
      tLocal = new ThreadLocal();
   }
 
   public final void outHTML(String strHTML){
      try {
         HttpServletResponse response = (HttpServletResponse) tLocal.get();
         byte[] buffer = strHTML.getBytes();
         response.setContentType("text/html");
         response.setHeader("Pragma", "no-cache");
         response.setDateHeader("Expires", 0L);
         response.setContentLength(strHTML.length());
         response.getOutputStream().write(buffer);
         response.getOutputStream().flush();
      } catch (Exception e) {
         e.printStackTrace();
      }
    }
}

 

相关文章:

  • 2022-01-31
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
猜你喜欢
  • 2021-12-18
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
  • 2022-01-23
相关资源
相似解决方案