public synchronized Servlet getServlet ( ) throws ServletException { // Handle previous unavailability if ( _unavailable != 0 ) { if ( _unavailable < 0 || _unavailable > 0 && System . currentTimeMillis ( ) < _unavailable ) throw _unavailableEx ; _unavailable = 0 ; _unavailableEx = null ; } try { if ( _servlets != null ) { Servlet servlet = null ; if ( _servlets . size ( ) == 0 ) { servlet = ( Servlet ) newInstance ( ) ; if ( _config == null ) _config = new Config ( ) ; initServlet ( servlet , _config ) ; } else servlet = ( Servlet ) _servlets . pop ( ) ; return servlet ; } if ( _servlet == null ) { _servlet = ( Servlet ) newInstance ( ) ; if ( _config == null ) _config = new Config ( ) ; initServlet ( _servlet , _config ) ; } return _servlet ; } catch ( UnavailableException e ) { _servlet = null ; _config = null ; return makeUnavailable ( e ) ; } catch ( ServletException e ) { _servlet = null ; _config = null ; throw e ; } catch ( Throwable e ) { _servlet = null ; _config = null ; throw new ServletException ( "init" , e ) ; } }
Get the servlet .