public void handle ( ServletRequest request , ServletResponse response ) throws ServletException , UnavailableException , IOException { if ( _class == null ) throw new UnavailableException ( "Servlet Not Initialized" ) ; Servlet servlet = ( ! _initOnStartup || _servlets != null ) ? getServlet ( ) : _servlet ; if ( servlet == null ) throw new UnavailableException ( "Could not instantiate " + _class ) ; // Service the request boolean servlet_error = true ; Principal user = null ; HttpRequest http_request = null ; try { // Handle aliased path if ( _forcedPath != null ) // TODO complain about poor naming to the Jasper folks request . setAttribute ( "org.apache.catalina.jsp_file" , _forcedPath ) ; // Handle run as if ( _runAs != null && _realm != null ) { http_request = getHttpContext ( ) . getHttpConnection ( ) . getRequest ( ) ; user = _realm . pushRole ( http_request . getUserPrincipal ( ) , _runAs ) ; http_request . setUserPrincipal ( user ) ; } servlet . service ( request , response ) ; servlet_error = false ; } catch ( UnavailableException e ) { if ( _servlets != null && servlet != null ) stop ( ) ; makeUnavailable ( e ) ; } finally { // pop run-as role if ( _runAs != null && _realm != null && user != null ) { user = _realm . popRole ( user ) ; http_request . setUserPrincipal ( user ) ; } // Handle error params. if ( servlet_error ) request . setAttribute ( "javax.servlet.error.servlet_name" , getName ( ) ) ; // Return to singleThreaded pool synchronized ( this ) { if ( _servlets != null && servlet != null ) _servlets . push ( servlet ) ; } } }
Service a request with this servlet .