Java Server Sent Events Chat Example

f
sxdvvxvcx
;k
m
k
sfsfs
fddf
h,g
SAAAAS
KRISHNA
KRISHNA
ASH
KRISHNANNNNNNNNN
KRISHASNANAJAJ
KRISJSJ
QQQQQQQQQQQQQQQQQQQQ
SDVFSDFADFADF
GSDGDSDFDFDF
GSDGDSDFDFDF
2222222222222222222222222222
dAD
sdf
sdfasd
fasdfsad
sdfasdfa
cacac
adasasas
xxxxxxxxxxxxxxxxxx
dafadfa
asdasdasdad
55565656565655555555555555555555555555555555555
sdfsdfsdfs
sdfdfsdfsdfsdf
dfsdf
dfgdfg
sdfdfsdfsfdf
หกดหกดหกดดกหกกดหกดหกดหกดหกดหกดหกดหกดห
หดกดหก
fsdfsdfs
fsdfs
df
dfsdfsdf
ssdfsdf
sdfsdfsdf
sdfsdfsf
hello
kkk
vignesh
klkl
ำพะำพะำพะ
กดเกดเกเ
Test
Vickuy
gggg
Test
1111
Test
Test2
3333
Test3
123456
test
hi
MUTHU
how r u
test
aass
SAdasasd
qweqweqweqweqwe
asdasd
lus
123\
asd
asd
sdsd
qwe
zxc
kanan
kiri
asdasd
Bla bla
Walou
dd
kaak
hello
hjdfhdsk
virendra
123
hello
Drum drum drum
olleh
112233
445566
test
test
create
hiii
hii

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