Java Server Sent Events Chat Example

rtrt
rtrt
rt
t
t
tttttttt
r
r
rt
rt
rtt
r
rt
t
t
rt
rt
rt
r
rt
ttttttttttt
t
t
rrrrrrrrrrr
r
rt
hello
sent using chrome
well i am sending this using mozilla
ok
test
1111
hi
test
1111
hi~~~~
test1111
11111
page2
page1
111
sdf
gdfgfgh
lll
lllllllll
l
l
l
hello chrome
hello chrome
mozilla
gjkg
kjh
a
Taufik
asdasd
rama monyet
rama monyet
wew
wew
wew
hamdan
ta
ew ew
awe
ewewewewewew
mjm
opp
poopp
dd
lkllk
sdfdgfdf
rrrh
eeee
lll
okkk
ppap
aaaaa
aaaa
hola
hola de nuevo
eeeeooo
parece que funciona
mantiene memoria en server
hola
caracola
adios
ok
2 clientes
ok
12
232
klk
ohou
Hi
How are you?
Hi
Hi
Hello
d

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