• 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

File Upload in Servlet failed for file size 2GB.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am doing file upload using JSP which is calling my Servlet at the backend. The Servlet is not able to upload file with size 2GB. When I looked at the httpRequest parameters in doPost method, I am getting negative value for contentLength (httpRequest.getContentLength()). Because of this negative value the issue is coming.

Any clues or suggestions on this?

Thanks in advance.
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sac Sha,

there could be multiple reasons

1. did u get outofmemory exception during the upload process on the server side.

2. u did not mention which jar or application frame work ur using means are u using orielly upload jar or using the struts framework both have certain parameters need to be set for large files.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That method returns an "int", which -being 32 bit long- is negative for values over 2GB. I haven't thought this through, but I think this implies that the current version of the Servlet API can't handle requests that large.
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a simple work around. You servelt has to request content length and if it's negative or number format exception happened, then process it as http header.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic