• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Upload in Servlet failed for file size 2GB.

 
Sac Sha
Greenhorn
Posts: 1
  • 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
  • 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
Posts: 42967
73
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic