Is there way to to use context handlers but also have a handle that doesn't catch all files that would normally be 404s? I'm making a HandlerList of ContextHandlers that map a url to a handler, but everything not caught seem to go to the last handler, which represents the homepage and shouldn't have anything after its slash. I want requests to
http://localhost/ to go to that handler and not requests like
http://localhost/some_file_that_does_not_exist_and_should_return_a_404.jpg, which currently goes to the Home handler.
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] {
Utils.createContextHandler(resourceHandler, "/static"),
Utils.createContextHandler(new Step1(), "/step1"),
Utils.createContextHandler(new Step2(), "/step2"),
Utils.createContextHandler(new Home(), "/") // <-- all 404s are going here
});
server.setHandler(handlers);
Is there not a way to set it by regex? For example, what if I were doing something like tinyurl, where I wanted a dynamic hash tag or number of some type sent to a specific handler? Could I send check if five digits exist, send to handler A and if it's six digits send to handler B? Or should I just create my own handler list that uses regexes? Or should I just put logic into my Home handler to catch weird files?