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).|
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" ... />