File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet being Called Twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet being Called Twice" Watch "Servlet being Called Twice" New topic

Servlet being Called Twice

Dan Lee

Joined: Oct 29, 2004
Posts: 1
Hi all,
This is my first post...I'm been having this problem for a while. My application is html/jsp and Servlets. When we hit a button on the jsp to kick off the servlet, it will run correctly and everything looks good. But after 5 minutes of processing, for some reason the servlet kicks off again??? I created a simple program and sure enough it does the same thing:

public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException {
// set action equal to which button was clicked

try {
System.out.println("*Start of Timeout Test Program*");

for(int i = 0; i< 20;i++) {
System.out.println("Timeout Test Program: " + i);

System.out.println("End of Timeout Test Program");
catch (Exception e) {}

This is running on a Windows NT Server and Websphere 4.0.3.

What makes me believe it's a setting issue is that when I run the same program on different Servers(we have 3 server, development, testing, and Production) the servlet kicks off at different intervals. On our Development Server the servlet kicks off twice after 16 minutes and for our testing and production servers it kicks off twice after 5 minutes.

Any help will be appreciated.
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
I feel that WebSphere thinks that your servlet is dead and kicks off another one to try to serve the request. Five minutes is a gigantic amount of time for a browser to wait for a response - most won't wait that long.

I'd guess that there is some sort of dead servlet/thread timeout happening and that the configurations between your servers are different.

I'd really encourage a different architecture. Perhaps the servlet can initiate processing and then whatever is doing the real work could put some sort of periodic status in the session. A JSP page could display the status. You could include something like:

in your JSP to have it periodically refresh the status.

<a href="" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
I agree. Here's the link:
subject: Servlet being Called Twice
It's not a secret anymore!