Code for uploading file in JSP/ Servlet using DataInputStream works well on Windows 7 running Apache Tomcat 7.0 (7.0.23) and uploads file correctly. But the same code when run on Apache Tomcat 5.0 in Linux platform is creating file of 0 bytes. The ownership and permissions of the folder to which files are getting uploaded have also been set but still gives the same problem. Please help.
Check for possible exceptions that could be happening on linux in the log files, make sure you are not hiding the exceptions to see them.
If you can't see them then post the code that you are using.
For starters, don't ignore the exception - print the stack trace to where you will see it; how else will you know if anything goes wrong? That applies to the exceptions in lines 59 and 124.
Two more points that have nothing to do with the problem at hand, but are strongly recommended best practices: 1) use PreparedStatement for interfacing with a DB instead of interpolated strings, and 2) GET and POST are not interchangeable. Any code that treats them as such (like this one) breaks the HTTP specification. A file upload should be a POST, never a GET.
Post by:autobot
Villains always have antidotes. They're funny that way. Here's an antidote disguised as a tiny ad:
a bit of art, as a gift, the permaculture playing cards