wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to increase maximum size of data accepted? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
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: 114
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: 12791
    
    5
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



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: 114
Thanks for the answers, I think Pete's answer should do the trick, as I had maxPostSize set to 2MB until now.
 
GeeCON Prague 2014
 
subject: How to increase maximum size of data accepted?