Hello, Unfortunately you're running up against a "bug" in Sun's implementation of the URLConnection class. Basically, the problem is that HTTP requires the content length to be set as a header. The implementation of the URLConnection takes the view that it can't know the content length until you've finished writing to the outputstream, so it uses an in-memory buffer to store your data until you've finished. This is why you are running into out of memory issues. Actually, if you took a look at your server log you'd find that your servlet never actually receives any data, since it's being buffered by the client outputstream and this runs out of memory before it is able to post the data. The annoying thing is that since you're uploading a file you do know the content length, so URLConnection could write the data directly. Unfortunately there's no way to set the content length on the URLConnection class. (When you set it via the line below you're just setting a header value - the URLConnection doesn't *know* that it's the content length). serverCon.setRequestProperty("Content-Length", Long.toString(fileToUpload.length()));