• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Request posted thrice

 
Pri Bahuguna
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Could anyone please tell me the reason for this.

I do not have doPost() method in the servlet.

Any suggestion will be welcomed.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pri Bahuguna:
I have created a web application where clicking on a hyperlink from one page does a sendRedirect to a Servlet.
Why does the link not address the servlet directly? How are you triggering the redirect? Code?

Could anyone please tell me the reason for this.
Not without seeing any code. Please be sure to use UBB code tags when posting code.
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic