Forums Register Login

Upload code in Java Servlet not working on Apache tomcat 5.0 on Linux platform

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Perhaps you could show us the code?
+Pie Number of slices to send: Send
A JSP file gets the filename to be uploaded.

The Servlet code for Uploading file is as follows:

+Pie Number of slices to send: Send
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.
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
https://gardener-gift.com


reply
reply
This thread has been viewed 1302 times.
Similar Threads
File Upload...strange
Upload File Error
JSP File upload
File Upload Using Servlets with LinuX and Tomcat
Java Coding Guidelines: Java finger-wagging
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:03:19.