You can also use third-party libraries for this, for example JBoss Netty and Apache MINA or Apache HTTP Comp . In addition, I donβt know much about this, but the new JDK7 has a new NIO apis that might also do the job.
Here is an example HTTP server written using Apache HC.
NOTE. I believe that the fashionable way to do such things is to use "Web Sockets", in which you will find information about this in the links that I provided.
source share