This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File upload problem

 
eddy johns
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

Can anyone please try to run the following code and see if it works? There's a FileUpload.html, calling a FileUpload.jsp, calling the FileUpload.java file and all of them do one simple thing: upload a file from the file system and write it to a location you specify. This is simple stuff and it works on my windows development machine but for some reason this code - or rather an identical one inside a larger application - fails on the client's deployment server (which is a unix machine.) It seems to read only two thirds of the image to the dataBytes array and then stops, and later in the code throws an IndexOutOfBounds exception. It writes the uploaded file to the correct path and with the correct name but with 0 bytes. This is baffling to me and I would really appreciate some help.

One possible reason that I can think of: the directory it needs to write to on the client's server is virtual, and running on a separate file server. Could this be the problem?

I apologize for posting this question a second time but I got no replies the first one and now I'm including all the relevant code. To run it you'll need to change the serverPath in the jsp file to a path on your machine.

Thank you very much for your help!
Eddy


Here are the files:









 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing to do with ORM; moving to servlets.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why wouldn't you just use an existing library to do all the busywork, like commons-fileupload?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David is right -- no experienced web developer is going to re-invent the wheel. See the JSP FAQ for information on the available libraries.
 
eddy johns
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I implemented the commons-fileupload and it works beautifully. Thank you very much, David and Bear!!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you got it working--that's great!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic