tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohun Biswas <>
Subject Re: error-page and POST vs GET
Date Fri, 02 May 2003 14:41:00 GMT

>What happens if you copy the code from doGet into the doPost method, 
>rather than call doGet from doPost?

Tried it, it changes nothing.

I've been able to reproduce this with a vanilla Tomcat 4.1.24 setup by 
adding a couple of tiny servlets plus the <error-code> mapping to the 
/examples context. I'm attaching these and I'd appreciate it if someone 
would try to reproduce. I'm beginning to think it's an actual bug. How to 

First, go to .../examples/WEB-INF/web.xml and add the following just below 
<servlet-mapping> and just above <taglib> (the modified web.xml is also 


Then just stick the two servlets into .../examples/WEB-INF/classes. One is 
called LabServlet and it simply throws a ServletException from either a GET 
or a POST. The other is ErrorHandlerServlet and it's supposed to "catch" 
the exception. Which it does as long as the request is a GET. What I do is 
comment out the "throw" statements just to ensure that the servlet is being 
called correctly, then turn on the throw and see POST do the wrong thing.

How you generate the request is immaterial, of course, but for the record 
I'm using the "curl" command-line tool on Unix. I create the GET request via

         curl localhost:8080/examples/servlet/LabServlet

and get the correct response

         In the error handler

I then make a POST by giving it some data:

         curl -d foo localhost:8080/examples/servlet/LabServlet

And get the standard HTML-ified stack trace just as if there was no 
<error-page>. The -v flag can be passed to curl to verify that the requests 
are GET and POST.

So: I've seen nothing in the spec that differentiates beween error-handling 
of GET vs POST but an actual difference is easily reproduceable in the 
latest production release. Is it a bug? Or is there some documentation I've 


View raw message