• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you could show us the code?
 
Prg Lakshmi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A JSP file gets the filename to be uploaded.

The Servlet code for Uploading file is as follows:

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic