dev@grizzly.java.net

update on comet-hidden

From: <Shing-Wai.Chan_at_Sun.COM>
Date: Wed, 23 Apr 2008 14:00:56 -0700

Hi,
I have updated the comet-hidden for the following:
- split the content of count.html into two frames so that the content of
the count will be updated correctly even when the requests are fast
- add comments on how to change from long-polling to http streaming
Thanks.
       Shing Wai Chan

elliptic: /export/grizzly/src/trunk/samples/comet/comet-hidden > svn diff .
Index: src/main/java/com/sun/grizzly/samples/comet/HiddenCometServlet.java
===================================================================
--- src/main/java/com/sun/grizzly/samples/comet/HiddenCometServlet.java
(revision 1019)
+++ src/main/java/com/sun/grizzly/samples/comet/HiddenCometServlet.java
(working copy)
@@ -56,7 +56,8 @@
                 PrintWriter writer = response.getWriter();
                 writer.write("<script
type='text/javascript'>parent.counter.updateCount('" + count +
"')</script>\n");
                 writer.flush();
-
+
+ // commented out the resume if it is Http Streaming
                 event.getCometContext().resumeCometHandler(this);
             }
         }
@@ -120,7 +121,7 @@
         CometEngine engine = CometEngine.getEngine();
         CometContext<?> context = engine.getCometContext(contextPath);
         context.notify(null);
- req.getRequestDispatcher("count.html").forward(req, res);
+ req.getRequestDispatcher("button.html").forward(req, res);
     }
     
 }
Index: src/main/webapp/index.html
===================================================================
--- src/main/webapp/index.html (revision 1019)
+++ src/main/webapp/index.html (working copy)
@@ -5,7 +5,8 @@
   <body>
     <frameset>
       <iframe name="hidden" src="hidden_comet" frameborder="0"
height="0" width="100%"></iframe>
- <iframe name="counter" src="count.html" frameborder="0"
height="100%" width="100%"></iframe>
+ <iframe name="counter" src="count.html" frameborder="0"
height="70%" width="100%"></iframe>
+ <iframe name="button" src="button.html" frameborder="0"
height="30%" width="100%"></iframe>
     </frameset></iframe>
   </body>
 </html>
Index: src/main/webapp/count.html
===================================================================
--- src/main/webapp/count.html (revision 1019)
+++ src/main/webapp/count.html (working copy)
@@ -3,6 +3,7 @@
     <script type='text/javascript'>
       function updateCount(c) {
         document.getElementById('count').innerHTML = c;
+ // comment location.href if it is Http Streaming
         parent.hidden.location.href = "hidden_comet";
       };
     </script>
@@ -13,10 +14,6 @@
       <p>
       <b id="count">&nbsp;</b>
       <p>
- <form method="post" action="hidden_comet">
- <input type="submit" value="Click">
- </form>
-
     </center>
   </body>
 </html>
Index: src/main/webapp/button.html
===================================================================
--- src/main/webapp/button.html (revision 0)
+++ src/main/webapp/button.html (revision 0)
@@ -0,0 +1,10 @@
+<html>
+ <body>
+ <center>
+ <form method="post" action="hidden_comet">
+ <input type="submit" value="Click">
+ </form>
+
+ </center>
+ </body>
+</html>