Download HTTP from a Java server

I need to write a small Java server that can be accessed through a web browser to download a file, preferably using sockets. Can someone point me in the right direction, as I can only find examples for the opposite (downloading from http using a java client).

Thanks,

Tom

+4
source share
3 answers

Do not reinvent the wheel, if you do not need, insert Jetty for this: http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty

+2
source

Depending on your requirements (e.g. protocol restrictions), you can start watching

Most of what this will lead to is:

  • How many difficulties do you want to do (time and energy)
+1
source

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.

0
source

All Articles