This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi Guys, I want my webserver to have "file upload" capabilities. Can I use Tomcat webserver in this case? Also, i don't know how to retrieve the attached file/s from client to the server (servlet). can anyone help me on this? pls provide code snippets if possible. thanks. Jonathan
Tano Ortiga
Greenhorn
Joined: Jan 03, 2001
Posts: 9
posted
0
Additional Questions: how do i "store" the file into an object/variable? how do i "store" the file into a database ? thanks again. Jonathan
Satish Kasala
Greenhorn
Joined: Dec 19, 2000
Posts: 16
posted
0
Jonathan, here's code for file upload. HTML: <form ENCTYPE="multipart/form-data" action="/servlet/FileUpLoad" method="POST"> <input name='upfile' type='file'> <input type="submit" name="Upload" value="Transfer the file"> </form> JavaCode: int iTotalBytes = this.oRequest.getContentLength(); BufferedReader oInFileData= new BufferedReader( new InputStreamReader(this.oRequest.getInputStream())); char[] arData = new char[iTotalBytes]; oInFileData.read(arData); arData contains the contents of the file as well as some more information regarding the request. you can filter out what you need from the array. Hope this helps Satish
Danny Mui
Ranch Hand
Joined: Dec 14, 2000
Posts: 42
posted
0
You can also obtain the O'reilly multi-part request handler (which parses an enctype of multipart that file-uploading requires). You can find the library at www.servlets.com.
Tano Ortiga
Greenhorn
Joined: Jan 03, 2001
Posts: 9
posted
0
thanks guys!
kaoalex
Greenhorn
Joined: Jul 12, 2001
Posts: 3
posted
0
Now,there is a html file in client. But i ave a question, if they are both java source code in client/Server. How to code in client??
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.