I had like to implement my own web-server in pure Java
the web-server should support only static resources (i.e. html, js, css, pics, movies etc..)
Can you recommend a tutorial or an article on how to implement such a thing?
should I use few processes or a thread-pool or should I consider a loop-event oriented like NodeJS?
I know there are free web-servers that does exactly what I am looking for, but I had like to do it as an exersice to my self.
I recommend familiarizing yourself with the HTTP request format http://datatracker.ietf.org/doc/rfc2616/. Implementing HTTP from scratch is no small feat, but it is certainly a good learning exercise.
Within Java itself for simplicity I recommend using a thread-per-request server – http://tutorials.jenkov.com/java-multithreaded-servers/multithreaded-server.html – that using
java.niofor serving files. In a concurrent settingjava.niois preferable tojava.iobecause it balances load better. You will likely find benchmarks that suggest thatjava.iois faster, but that is for sequential single-threaded code.