Sunday, April 22, 2012

A small Tutorial on HTML5 Server Sent Events (Part-II) using TOMCAT server

NOTE: Please visit my previous blog post SSE-Part-I  which gives detailed information from basics.
This blog post mainly concentrates on designing SSE server side code on TOMCAT server using servlets. If you have visited my previous blog post, the server side code was implemented on WAMP server using perl script. For people who are java, j2ee and TOMCAT lovers like me should go through this.

Basic idea needed:

  1. Tomcat server
  2. SSE basics
  3. J2EE servlet concepts

Example 1:
Here i'll be using Eclipse IDE to demonstrate the examples. Make sure you have directory structure for a Dynamic web project like this:
  1. Created a package under Java resources called com.zinnia.server and placed the servlet named 
  2. index.html is the page from where the event source would be registered.
The code is as follows:



Go to the url http://localhost:8080/SSE_Test/index.html and see the time ticking which is actually being sent by the server.