title: how to limit post size in tomcat 8? How to make a custom reply for it?
body: <p>I have this configured in my server.xml file</p>
  
  <pre><code>&lt;Connector URIEncoding="UTF-8" connectionTimeout="20000" maxHttpHeaderSize="65536" **maxPostSize="1024"** port="8080" protocol="HTTP/1.1" redirectPort="8443"/&gt;
  </code></pre>
  
  <p>However, requests more than 1 KB pass as if maxPostSize is never set. Can anyone suggest what can cause that?</p>
  
  <p>Another thing, I would like to know how to make a custom http reply from tomcat if the post size is more than 1 KB</p>
  
  <p><strong><em>UPDATE</em></strong>
  Since I have been for so long in this issue. I had the opportunity to look at the source code for tomcat to check what is happening here exactly:
  <a href="http://www.docjar.com/html/api/org/apache/catalina/connector/Request.java.html" rel="noreferrer">click here</a></p>
  
  <p>I noticed from lines 2541 till 2550, they are using getContentLength() although the documentation says "maxPostSize: The maximum size in bytes". How come could this be in bytes? It looks more to characters count to me and it can be done in servlet side. Can someone explain what I am missing here?</p>