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:
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:
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:
- Tomcat server
- SSE basics
- 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:
- Created a package under Java resources called com.zinnia.server and placed the servlet named SendResponse.java.
- index.html is the page from where the event source would be registered.
The code is as follows:
//SendResponse.java
//index.html
Go to the url http://localhost:8080/SSE_Test/index.html and see the time ticking which is actually being sent by the server.
Thanks for the article!
ReplyDeleteWould be better if the code is presented as actual text instead of it being captured in the screenshots as it is not possible to copy/paste text from screenshots to try out the code.
Great post! Thank you very much :)
ReplyDeletewhat is this...
ReplyDeletethis is normal data to display after every five seconds that we can do normally in jsp page
starting loop with true and then sleeping thread for 5 sec
if you add this code in JSP page it will work
where is server sent event ?????????????????
This simple code seems to work normally in JSP pages. But you can use it to push notifications to clients too!
DeleteGreat Post ! HTML5 tutorial with simple and easy examples, Covering HTML5 Introduction, Semantic Elements,Attributes,Canvas,SVG,Multimedia,Video,Audio,Plug-ins,YouTube Videos, Geolocation, Drag and Drop, Local Storage, Coding Conventions / Style Guide. HTML5 Tutorial & CSS3 Tutorial.
ReplyDeleteThank you very much for this simple but excellent post. This can be used for any event on server side and make push notification to the client I guess!
ReplyDeleteyurtdışı kargo
ReplyDeleteresimli magnet
instagram takipçi satın al
yurtdışı kargo
sms onay
dijital kartvizit
dijital kartvizit
https://nobetci-eczane.org/
WFL
salt likit
ReplyDeletesalt likit
dr mood likit
big boss likit
dl likit
dark likit
A0H