I have created a web application where clicking on a hyperlink from one page does a sendRedirect to a Servlet. The doGet() method of the servlet does some processing based on parameters sent through the URL.
But in the logs I can see that this doGet() method is being called three times when the hyperlink is clicked once. This is happening every time.
Maybe you don't really mean that you're calling sendRedirect? If so, I think that the behavior you're seeing is probably caused by the confluence of these facts:
- The resource that your link points to would need to be retrieved by the HTTP GET method. - Your browser has the ability to cache the result of prior GET requests for that resource. - When your browser has a cached copy of the resource that you need to GET, it will first send a HEAD request to see if the cached copy is stale. - The default implementation of doHead(..) in HttpServlet makes a call to doGet(..).
The above facts will account for at least two of the times that you're seeing the doGet(..) method being called for a single URL click. [ August 11, 2008: Message edited by: Dave Wingate ]