public void removeServlet ( String name , String pathSpec , Class < ? extends HttpServlet > clazz ) { if ( clazz == null ) { return ; } //remove the filters from filterPathMapping ServletHandler servletHandler = webAppContext . getServletHandler ( ) ; List < FilterMapping > newFilterMappings = new ArrayList < FilterMapping > ( ) ; //only add the filter whose pathSpec is not the to-be-removed servlet for ( FilterMapping mapping : servletHandler . getFilterMappings ( ) ) { for ( String mappingPathSpec : mapping . getPathSpecs ( ) ) { if ( ! mappingPathSpec . equals ( pathSpec ) ) { newFilterMappings . add ( mapping ) ; } } } servletHandler . setFilterMappings ( newFilterMappings . toArray ( new FilterMapping [ newFilterMappings . size ( ) ] ) ) ; removeInternalServlet ( name , pathSpec , clazz ) ; }
Remove a servlet in the server .