public void handle ( String pathInContext , String pathParams , HttpRequest request , HttpResponse response ) throws HttpException , IOException { // exempt error pages // TODO This probably should be more general? if ( request . getAttribute ( "javax.servlet.error.status_code" ) != null ) return ; try { String ip = request . getRemoteAddr ( ) ; boolean authorized = checkIP ( ip ) ; if ( ! authorized ) { // The IP is NOT allowed response . sendError ( HttpResponse . __403_Forbidden ) ; request . setHandled ( true ) ; return ; } else { // The IP is allowed return ; } } catch ( Exception ex ) { System . out . println ( ex ) ; response . sendError ( HttpResponse . __500_Internal_Server_Error ) ; request . setHandled ( true ) ; } }
Handles the incoming request