This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Upload in Servlet failed for file size 2GB.

 
Sac Sha
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Satish SN
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
dema rogatkin
Ranch Hand
Posts: 294
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic