【web】http长连接技术(3)http push的jsp实现

时间:2022-08-22 15:14:05

   标签:web  push jsp

push-html-stream.jsp
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <meta http-equiv="Pragma" content="no-cache">
</HEAD>
<BODY BGCOLOR="blue" TEXT="white">
<%
  try {
    for (int i=1; i < 10; i++) {
       out.print("<h1>"+i+"</h1>");
       out.flush();
     
       try {
            Thread.sleep(3000);
       } catch (InterruptedException e) {
            out.print("<h1>"+e+"</h1>");
       }
     }
   } catch (Exception e) {
       out.print("<h1>"+e+"</h1>");
   }
   out.print("<h1>DONE</h1>");

%>
</BODY>
</HTML>