While working on web applications, developers face common server errors and exceptions in java based web application for example java.lang.IllegalArgumentException.
Lets explore this problem and what causes it:
Tomcat Server is basically a servlet container. When a web application is deployed into tomcat, tomcat scans the Web app , reads its deployment descriptor (web.xml) and decides that Servlets need to be deployed and be made available. Servlets and JSPs are loaded based on a class loader hierarchy, also any listeners and filters relevant are loaded and made available.
When a request comes it is sent to the appropriate Servlet class (which runs in a separate thread), the servlet does what is necessary to process the request, responds, then the thread is free and will be used to serve the next request.
The most common error early web developers is “Request Header is too large“. It is not entirely known that it is a server error and not application error.
|The maximum size of the request and response HTTP header, specified in bytes. If not specified, this attribute is set to 4096 (4 KB).|
Source: Apache Tomcat Configuration Reference
See image below:
To resolve this error, either check if the request made is GET or POST?
If it is GET request then change it to HTTP POST the error will get resolved in most of the cases as the URL length goes beyond 2000 characters. In this case, it’s better to use POST or split the URL.
maxHttpHeaderSize: The maximum size of the request and response HTTP header, specified in bytes. If not specified, this attribute is set to 4096 (4 KB).
You will find it in
In server.xml change the HTTP/1.1 Connector entry and set the maxHttpHeaderSize to “65536” (64Kb in bytes) as shown below:
<Connector port="8080" maxHttpHeaderSize="65536" protocol="HTTP/1.1" ... />
4 thoughts on “Tomcat: Request Header too large? Resolved!”
Could this be related to the client (Chrome on Win10) in any way? I have a user that is getting this error (Request header is too large) when opening a link from Wells Fargo website when clicking on it in Chrome. If she uses Edge, it opens fine but not in Chrome. She called their tech support and they told her the issue was on our end, contact our I.T. dept. Everything I read on this points to the header limitation in Tomcat but how does it work in one browser but not the other…? Appreciate any feedback before I contact their tech support.