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.
When a servlet is called from other servlet using include or forward method of RequestDispatcher, at that time, are doGet or doPost methods (of called servlet) called from calling servlet??? Will someone elaborate this point, I mean explain flow of programm for same above. I will be hightly obliged.
when we do forward(), it means we are passing control to a new web resource, in your case to a servlet. now the new resource, which we have passed the control, is supposed to commit the response.
when we do include(), it means we are passing the control to a new web resource for some processing but the control would be back to the same resource. now the new resource, which we have passed the control, is supposed to process the request or manipulate the response but not commit the response. response would be commited by the same resource that has passed the control to a new resource for some processing only.
and about the method calling. no servlet calls the method doPost() or doGet() of any other resource. container knows which method it should call. because the request object has the method, by which the request is made. we can get that using request.getMethod(). now as we pass the request and response in our forward() and include() method, thus we need not worry.