javaservletscomet

Servlet 3.0 async Timeouts


Is it possible to extend the timeout of a servlet 3.0 async servlet. I tried to do it in the timeout method but is still completed the async request.

What is the best way of extending the timeout such that the async servlet never completes

Tx


Solution

  • Its about time that you haven't got any reply. So here I am breaking the silence :P

    AsyncContext cntx = request.startAsync(request, response);
    
    long timeOut = DEFAULT_TIME_OUT;
    
    
    if( req.getParameterMap().containsKey( TIME_OUT ) ){
        try {
            timeOut = Long.parseLong( req.getParameter( TIME_OUT ) );
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }
    
    cntx.setTimeout( timeOut );