aspose file tools*
The moose likes Servlets and the fly likes Servlet Request posted thrice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Request posted thrice" Watch "Servlet Request posted thrice" New topic
Author

Servlet Request posted thrice

Pri Bahuguna
Greenhorn

Joined: Aug 10, 2008
Posts: 1
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

Joined: Jan 10, 2002
Posts: 61430
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
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 ]

Fun programming etcetera!
 
wood burning stoves
 
subject: Servlet Request posted thrice