This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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 ]