This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Yes, it's from Chrome. However, I didn't do redirection multiple times. I'm still following the same code that I posted initially but with changes suggested by you. I still don't understand the reason behind such error.
Here program logic is correct. When we made a request like then container sees the url-pattern here it is '/' and mapps it to the servlet 'CoffeeSelector' calls doGet() which calls doPost(). The 'doPost' checks the request parameter 'coffee'. Here it is 'null'. Then it redirects to the static source 'index.html'.
Here container sends the response header as 'http://localhost:8080/3/index.html'. Here we have override the default servlet that is present in 'conf/web.xml'. The main purpose of the default servlet is to serve static resources like html files, image files etc.
Suppose when a request comes to the servlet like If we didn't override the default servlet, then the default servlet checks the type of the resource, wether it is static or dynamic resource. If it is static resource, it will handle and serve to the client.
Here we have overriden the default servlet's protected methods, doGet and doPost. Now the browser redirected as Now the default servlets method's that handles wether the resource is static or dynamic resource's will be called(since we have not overriden those methods) and decides wether it is static or dynamic resource. Here it is 'yes' calls the overriden doGet method and which calls doPost method. Now it checks the request parameter 'coffee' here it is 'null' and redirect the static resource as Again the browser sends the request to the container and the container decides the type of resource, the procedure is same as above. This recursion will be done many times. Browser will not be able to display the response. It will not be able to handle this. So it displays the message to the user as
Thanks so much Chinmay! Your reply cleared my doubt. But, I have a new question based on your reply - in my program, for default servlet, is 'index.html' static/dynamic? You said about default servlet's methods that check whether a resource is static/dynamic; could you tell what are those methods? Is there any web link where I could understand more about default servlet's behaviour?