70

I'm troubleshooting a Java app where XML is sent between two systems using HTTP POST and Servlet. I suspect that the problem is that the XML is growing way too big. Is it possible that this is the problem? Is there a limit?

When it doesn't work, the request.getParameter("message") on the consumer side will return null. Both apps are running on TomCat. For instance, an XML document of size 1.73mb will not make it through.

l3dx
  • 2,868
  • 6
  • 30
  • 40

4 Answers4

107

As per this the default is 2 MB for your <Connector>.

maxPostSize = The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).

Edit Tomcat's server.xml. In the <Connector> element, add an attribute maxPostSize and set a larger value (in bytes) to increase the limit.

Having said that, if this is the issue, you should have got an exception on the lines of Post data too big in tomcat

For Further Info

Community
  • 1
  • 1
JoseK
  • 30,355
  • 14
  • 98
  • 129
  • Thanks for your answer. I managed to get it working. I did not get any exceptions, but for what I know, it might have been caught somewhere inside this legacy dungeon – l3dx May 31 '10 at 13:16
  • I indeed was having the same problem but I think I didn't receive the mentioned error using jboss 4. Then again, I could just have overlooked it – Toskan Nov 21 '12 at 11:53
  • 2
    Is ti possible to specify this limit from within my application rather than editing tomcat's server.xml ? – Rajat Gupta Feb 17 '15 at 06:52
  • In my Tomcat 8 the value for maxPostSize=0 did not mean "unlimited". A value of -1 did the trick. – s1m3n Feb 08 '19 at 12:49
6

There is no defined maximum size for HTTP POST requests. If you notice such a limit then it's an arbitrary limitation of your HTTP Server/Client.

You might get a better answer if you tell how big the XML is.

Morfildur
  • 12,196
  • 6
  • 32
  • 54
  • 1
    Referring to the [Inline Apache Tomcat Documentation for TOMCAT 5.5](https://tomcat.apache.org/tomcat-5.5-doc/config/http.html), the default value for maxPostSize (if not specified), is set to 2097152 (2 megabytes) – Halayem Anis Jan 17 '18 at 12:51
1

There may be a limit depending on server and/or application configuration. For Example, check

František Žiačik
  • 6,925
  • 1
  • 29
  • 51
0

Yes there is 2MB max and it can be increased by configuration change like this. If your POST body is not in form of multipart file then you might need to add the max-http-post configuration for tomcat in the application yml configuration file.

Increase max size of each multipart file to 10MB and total payload size of 100MB max

 spring:
    servlet:
      multipart:max-file-size: 10MB
      multipart:max-request-size: 100MB
 

Setting max size of post requests which might just be the formdata in string format to ~10 MB

 server:
    tomcat:
        max-http-post-size: 100000000 # max-http-form-post-size: 10MB for new version

You might need to add this for the latest sprintboot version ->

server: tomcat: max-http-form-post-size: 10MB

Asif Karim Bherani
  • 805
  • 1
  • 10
  • 25