(cont,,) // set HandlerCollection in Server server.setHandler(createHandlers());
My first RewritePatterRule seems to be working fine. The RewriteRegexRule gives me a 404 error for edit.html. Both admin.html and edit.html are in the same webapp folder (actually the webapp root). I have debugged Jetty code and the regex is definitely working (in fact it's looking for edit.html). But why a 404 error?! I have this tinkling feeling that it might be related to the contextPath and warPath. The warPath is definitely ok with the server starting and I am making calls to rest services from admin.html and edit.html. So that's fine. Any ideas? I am using Jetty 8.1.5.v20120716 Thanks, Melissa On Tue, Dec 11, 2012 at 11:38 AM, Melissa Mifsud < [email protected]> wrote: > Hi! > > I've been battling with this problem for a while now. I have set up 2 > rewrite rules as follows: > > // Set up rewrite handler and rules > RewriteHandler rewriter = new RewriteHandler(); > rewriter.setRewritePathInfo(true); > rewriter.setRewriteRequestURI(true); > rewriter.setOriginalPathAttribute("requestedPath"); > > RewritePatternRule admin = new RewritePatternRule(); > admin.setPattern("/admin/"); > admin.setReplacement("/admin.html"); > rewriter.addRule(admin); > > RewriteRegexRule edit = new RewriteRegexRule(); > edit.setRegex("/edit/([A-Za-z0-9-_]+)"); > edit.setReplacement("/edit.html?dashboard=$1"); > rewriter.addRule(edit); > > // Set up the WebAppContext and add the rewrite handler to it > WebAppContext _ctx = new WebAppContext(); > _ctx.setContextPath("/"); > _ctx.setWar(PATH_TO_WEBAPP); > _ctx.setHandler(rewriter); > > // Set up context handlers > List<Handler> _handlers = new ArrayList<Handler>(); > _handlers.add(_ctx); > HandlerList _contexts = new HandlerList(); > _contexts.setHandlers(_handlers.toArray(new Handler[0])); > > // Set up the handler collection > HandlerCollection _result = new HandlerCollection(); > //_result.setHandlers(new Handler[] {_contexts, _log}); > _result.setHandlers(new Handler[] {_contexts}); > > > > > -- ------------------------------ *Melissa Anne Mifsud* Email <[email protected]> - Twitter<http://twitter.com/#%21/melmifsud> - LinkedIn <http://mt.linkedin.com/in/melissamifsud> **
_______________________________________________ jetty-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/jetty-users
