struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mischa o <strutsuser...@yahoo.com>
Subject Action class time out logic
Date Thu, 19 Jun 2003 15:56:55 GMT

Hi Guys:
 I have an action class that delegate to the business layer for 
processing. Sometimes it takes a long time to do the processing. I would like 
to have a timeout of say 2 minutes, I couldnot implement the timeout in 
the jsp page, because it is the action class which is doing the 
processing logic and until the execute method returns, the jsp is never 
executed. So How could i implement the time out in the action class.
 
I tried to implement a timer using the timer class. but still it 
doesnot work, the response is not flushed  until the execute method returns, 
that means the time it take to finish the processing of the business 
logic. 
-- code for timer--
new TimerTask(){
 run()
  {
      System.out.println("timer ended");
      ActionErrors errors = new ActionErrors();
      errors.add(ActionErrors.GLOBAL_ERROR, new 
ActionError("error.timeout"));
      if (!errors.isEmpty())
           request.setAttribute(Globals.ERROR_KEY, errors);
      try
      {
        PrintWriter out = response.getWriter();
        out.write("timeout");
        out.flush(); 
//        response.sendRedirect(request.getContextPath());
//        response.flushBuffer();
        System.out.println("send to browser");
      }
      catch(IOException ex)
      {
        System.out.println("IO EXCEPTION");
      }
  }
}
even though i did write something to the response stream, the response 
is not send until the execute method returns. any ideas why?
I believe someone might have done this and could help out . 
Thank you for your time and effort. a sample code will be greatly 
appreciated
 
cheers 



---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message