Java Server Sent Events Chat Example

da
daaaa
dadaaa
da
dadaada
test
test
test
tst
test
test
haha
xcvx
hi
heloo
what's up
fykkghl
uop
hello
fuck
aaaaa
范泰然
asdf
asdf
asdf
firefo
firefox
firefox
Hello all
firefox with multi tab
asdf
asdfds
asdf
asdfds
asdf
asdf
asdf
asdf
asdf
asdf
asdf
asdf
asdf
asdf
asdf
asdf
qw
Hello all
test
hello you
can you see the history?
test
dfsdf
test
tt
rrrr
wdwdw
cccccccccccccccccccc
io
op
wdawd
黑哦了
groot
this example is exactly good
I am groot
more groot
hello
namengama?
HELLO
Hello
hi
hii
hui
yo
hi
test
55555
Deepak
Deepak gsdgsd
sdgsdgsd
sdsdgsd
Eeepa
Deepak Nagaraj
Is it here
Pawan
not here
I am groot
sss
sss
78568
test
ttttt
typing
googd
refresh
working
test
ppp
test
cfafg

Enter message in the field above and press Enter to send it.

This is a simple Java Server Sent Events chat example. It illustrates usage of technology - how with a few lines of code you can achieve simple chat application working in a modern browsers.

Of course this simple example gives you only basics functionality. Further you can improve it. Also you can consider using this technology for other areas where it is required mostly one way communication. E.g. client is subscribed and listen to changes such as price change, status update, live scores, etc.

To test it open this page in two different browsers. Note that Internet Explorer does not support SSE. So use Google Chrome and Mozilla Firefox.

For more info you can read following article Introduction to SSE with PHP example or directly look into SSE PHP example that updates stock prices when market moves.

Download source code Download WAR file Read Java SSE article