It's got nothing to do with the casting. If you call a method from itself (recursion) you will create an endless loop that adds method calls to the stack with each iteration until you run out of memory. [ August 29, 2006: Message edited by: Ben Souther ]
In case 1 (the posted code), there is a call from the service() method of the Servlet to the super class (HttpServlet) service() method (the one that accepts HttpServletRequest & HttpServletResponse). This method in the HttpServlet class examines the method of the request and calls the doXXX() methods on the subclass Servlet. (works fine)
a call to the super class's overloaded service method (the one that accepts ServletRequest & ServletResponse objects) is made. Now the javadoc for this method has this to say
Dispatches client requests to the protected service method. There's no need to override this method.
The protected service method in question is the one that accepts HttpServletRequest and HttpServletResponse and which has been overridden in the sub class Servlet. The subclass's service method gets called. So there.....
This had me stumped for a while as my first impressions were consistent with Majid's (casting problem). However I couldnt understand the infinite loop until I looked up the javadoc