Is there a max size for POST parameter content?

TomcatServletsHttp Post

Tomcat Problem Overview


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.

Tomcat Solutions


Solution 1 - Tomcat

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

Solution 2 - Tomcat

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.

Solution 3 - Tomcat

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

Solution 4 - Tomcat

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionl3dxView Question on Stackoverflow
Solution 1 - TomcatJoseKView Answer on Stackoverflow
Solution 2 - TomcatMorfildurView Answer on Stackoverflow
Solution 3 - TomcatFrantišek ŽiačikView Answer on Stackoverflow
Solution 4 - TomcatAsif Karim BheraniView Answer on Stackoverflow