Java Server Sent Events Chat Example

kk
mm
mm
hi
lets test this
This is slow, how does it work?
dfghj
ciao nino
ciao
sdfdf
yjgjg
ghh
jh
tttt
hi
yyyy
jjjjj
kkkkkkkkkkkkkkkkkk
ggggggggggg
ggg
sss
rrrr
uuuuuuuuuuuuu
ffffffffffffffffff
iiiiiiiiiiiiiiiiiiiiiiiiiiiii
iiiiiiiiiiiiiiiiii
pppppppppppppppp
jjjjjjjjjjjj
kkkkkkkkkkkkk
kkkkkkkkkkkkkkkkkk
hjklj
jjj
hi
gfh
fgh
llll
hihihihihihi
njnjjjnjjjnjnjnjjn
151515155151
dd
hiiiiiiiiiiiiiiiiiiiiiiiiii
uo
sfds
safd
bala111
kkk111
l
ddd
hao
afsffsfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
fffffffff
f
f
f
f
fff
pipp
hello
hi po
mahal q kau
iompuiom
hai
Man whats your name
no
q\q\\\\\
<>


test
abc
รถ
hi
hi
ehi Bella gente!!!
ehi Bella gente!!!
hello
a kuku
jjjj
xxxxxxxxxxxx
l
test
omg
aaaaa
aad
dddddddds
sssdddd
ddddd
hola
ass
aass
aqq
sss
aaa
javier
javier
Hello
hi
Hello
ssdss sdw
hello

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