Dear all,
I custom the error page in web.xml as below:
<error-page>
<error-code>400</error-code>
<location>/error400.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/error404.html</location>
</error-page>
<error-page>
<exception-type>java.lang.IllegalArgumentException</exception-type>
<location>/error404.html</location>
</error-page>
And I added some log action in org.apache.catalina.util.ErrorPageSupport
and found out that in some case the 400 error page not working but the
default error page.
the log action is:
public ErrorPage find(int statusCode) {
log.info("before find, the length of statusPages
is:"+statusPages.size());
log.info("in addErrorPage find by status Code ************ code
is:"+statusCode );
log.info(Integer.valueOf(statusCode));
if ( statusPages.get(Integer.valueOf(statusCode)) == null )
log.info("cannot find for "+statusCode);
else
log.info("find:"+statusPages.get(Integer.valueOf(statusCode)).getLocation()
);
return statusPages.get(Integer.valueOf(statusCode));
}
the log print out is:
20:02:59.674 INFO [http-nio-8080-exec-1]
org.apache.coyote.http11.Http11Processor.service
Error parsing HTTP request header
Note: further occurrences of HTTP request parsing errors will be logged at
DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in the request
target. The valid characters are defined in RFC 7230 and RFC 3986
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(
Http11InputBuffer.java:463)
at org.apache.coyote.http11.Http11Processor.service(
Http11Processor.java:298)
at org.apache.coyote.AbstractProcessorLight.process(
AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(
AbstractProtocol.java:754)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.
doRun(NioEndpoint.java:1385)
at org.apache.tomcat.util.net.SocketProcessorBase.run(
SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(
TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
20:02:59.690 INFO [http-nio-8080-exec-1]
org.apache.catalina.util.ErrorPageSupport.find
before find, the length of statusPages is:0
20:02:59.690 INFO [http-nio-8080-exec-1]
org.apache.catalina.util.ErrorPageSupport.find
in addErrorPage find by status Code ************ code is:400
20:02:59.690 INFO [http-nio-8080-exec-1]
org.apache.catalina.util.ErrorPageSupport.find
400
20:02:59.690 INFO [http-nio-8080-exec-1]
org.apache.catalina.util.ErrorPageSupport.find
cannot find for 400
20:02:59.690 INFO [http-nio-8080-exec-1]
org.apache.catalina.util.ErrorPageSupport.find
before find, the length of statusPages is:0
20:02:59.691 INFO [http-nio-8080-exec-1]
org.apache.catalina.util.ErrorPageSupport.find
in addErrorPage find by status Code ************ code is:0
20:02:59.691 INFO [http-nio-8080-exec-1]
org.apache.catalina.util.ErrorPageSupport.find
0
20:02:59.691 INFO [http-nio-8080-exec-1]
org.apache.catalina.util.ErrorPageSupport.find
cannot find for 0
20:02:59.999 INFO [http-nio-8080-exec-2]
org.apache.catalina.util.ErrorPageSupport.find
before find, the length of statusPages is:2
20:03:00.000 INFO [http-nio-8080-exec-2]
org.apache.catalina.util.ErrorPageSupport.find
in addErrorPage find by status Code ************ code is:404
20:03:00.000 INFO [http-nio-8080-exec-2]
org.apache.catalina.util.ErrorPageSupport.find
404
20:03:00.000 INFO [http-nio-8080-exec-2]
org.apache.catalina.util.ErrorPageSupport.find
find:/error404.html
Is it a known bug or I can get some patch for it ? Thanks advanced.
Sincerely
Leo