Uploading files via servlet

E

El Durango

I have written a simple servlet which will read the servlet inputstream and
create a file. The java client will open a file and write it to the servlet
using URLConnection. Now it works but I have to set a file name through the
servlet as hardcoded. If I pass the filename through client to servlet it
will not work b/c it will also think the file content is part of the
filename. If I have the servlet retrieve the filename as a parameter it
will get the name but will not read the stream to create the file??
Can anyone help me on this?
I am confused on what is a good way of uploading a file with the name, I
think I am almost there but the above issues have been plaguing me.
I researched through Google and could not find the necessary info.

thank you in advance.
 
F

Fedor

El Durango said:
I am confused on what is a good way of uploading a file with the name, I
think I am almost there but the above issues have been plaguing me.
I researched through Google and could not find the necessary info.
Check out FileUpload library from apache commons:

http://jakarta.apache.org/commons/fileupload/

I used this one to handle multipart-posts to
a servlets. Using this library, it's quite
straightforward.


kind regards,

fedor
 
N

news.skynet.be

Hello, a bit unrelated, but I am trying to do the bit you seem to have
achieved the:
The java client will open a file and write it to the servlet
using URLConnection

is there any chance you could share your code for getting the file from the
client into the url connection, I have only succeded with text input so far.

thanks for your time reading this.

cheers
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top