Home >Java >javaTutorial >How to Increase the Maximum HTTP Request Size in Tomcat?
Customizing Maximum HTTP Request Size for Tomcat
Problem:
When using HttpURLConnection to send data to a Tomcat server, what is the maximum size limitation for the request? Can this limit be modified?
Solution:
To modify the maximum allowable request size in Tomcat, you need to adjust two parameters:
In the confserver.xml file, locate the Connector element that defines the HTTP port. Add or update the maxPostSize attribute with the desired maximum request size in bytes.
<code class="xml"><Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" maxPostSize="67589953" /></code>
In the webappsmanagerWEB-INFweb.xml file, find the multipart-config element. Configure the max-file-size and max-request-size attributes to specify the maximum file and request sizes allowed.
<code class="xml"><multipart-config> <!-- 52MB max --> <max-file-size>52428800</max-file-size> <max-request-size>52428800</max-request-size> <file-size-threshold>0</file-size-threshold> </multipart-config></code>
Once these changes are made, Tomcat will accept HTTP requests up to the specified maximum size limits.
The above is the detailed content of How to Increase the Maximum HTTP Request Size in Tomcat?. For more information, please follow other related articles on the PHP Chinese website!