This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to increase maximum size of data accepted? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "How to increase maximum size of data accepted?" Watch "How to increase maximum size of data accepted?" New topic
Author

How to increase maximum size of data accepted?

Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 113
hi,

for some time I am looking for clear answer, how to increase maximum size of data, that comes to servlet in the request? I have a servlet that receives xml data from another server. I have been told by admin of that another server, to increase the maximum allowed size to 6MB, shoot me but I have no clue where to set it. When some bigger data comes, their server is sending it all the time, because no successful status comes from mine.

By maximum size of data I mean max size of request's parameter(s) (String xml = request.getParameter("data");)

Regards,
Michal
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12268
    
    1
The usual use of getParameter is for relatively short Strings from a HTML form submission.

If somebody was trying to POST megabytes of text to my servlet, I would avoid all the methods (such as get Parameter) which trigger the servlet container into trying to interpret the input as a form. Instead I would get the request body as a stream and try to process that.

See javax.servlet.ServletRequest.getInputStream()

With stream input you could process XML as either a Document or with a SAX or Stax parser.

What do you have to do with this XML?

Bill




Java Resources at www.wbrogden.com
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

It will depend on the server container you are using.

If you are using Tomcat directly, you can set the maxPostSize attribute for your http-connector (or ajp connector) to allow a 6 MB file. By default, Tomcat's HTTP (and AJP) connector limits this to 2 MB. See http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

For other server containers, look for a similar setting in their documentation - they are very likely to have a similar setting.


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 113
Thanks for the answers, I think Pete's answer should do the trick, as I had maxPostSize set to 2MB until now.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to increase maximum size of data accepted?
 
Similar Threads
size of post data? ways of sending large data?
java.net.SocketException: Software caused connection abort: socket write error
Mark Hansen - Converting servlet design to Webservices
Tomcat and Optimizeit throwing Out of memory error
Dynamic Array Resizing