Hi all,

I have a .war deployed in Jetty 7.2.0 which has two main entry points, a user page and an admin page. I'd like a request to http://my.server.com to result in '/index.jsp' to be returned, and a request to http://my.server.com/admin to result in '/admin/adminIndex.jsp' to be returned. The whole site was working perfectly until I introduced RewriteHandler, and now I find <jsp:include> statements fail silently.

I'm running embedded Jetty for local development, but presumably this would all operate the same once I put the config in a context .xml file. I tried adding the Rewrite handler like this:

WebAppContext webApp = new WebAppContext(warUrlString, CONTEXTPATH);
        // ... other setup

        RewriteHandler rewrite = new RewriteHandler();
        rewrite.setRewriteRequestURI(true);
        rewrite.setRewritePathInfo(false);
        rewrite.setOriginalPathAttribute("requestedPath");

        RedirectRegexRule rule = new RedirectRegexRule();
        rule.setRegex("^/$");
        rule.setReplacement(CONTEXTPATH + "/index.jsp");
        rewrite.addRule(rule);

        RedirectRegexRule rule2 = new RedirectRegexRule();
        rule2.setRegex("^/admin$");
        rule2.setReplacement(CONTEXTPATH + "/admin/login.jsp");
        rewrite.addRule(rule2);

        webApp.setHandler(rewrite);

I've chosen RedirectRegexRule because I had trouble with RedirectPatternRule, not being sure what patterns match what. Regex seems to do an identical job, with syntax I'm more familiar with.

Unfortunately I've found that while the rewrites seem to work, my <jsp:include> statements now fail. Taking out this Rewrite handler fixes them again. For example, a /welcome.jsp page contains:

<jsp:include page="CustomPageContent.jsp?page_name=welcomeGuest"></jsp:include>

which fails silently with the Rewrite handler in place (no exceptions, no output, logger statements in CustomPageContent.jsp are not executed, I've no idea how to debug it).

So, questions:

1/ Am I right to use RewriteHandler for the task of allowing users to enter simple URLs and be redirected to more specific URI's within my site? Perhaps I should use a web.xml <welcome-file-list> directive for the simple "/"->index.jsp redirect, but what about the "/admin"->admin/adminIndex.jsp one?

2/ How should I fix things so my <jsp:include> tags operate correctly again?

Any other comments would be most welcome :)

Thanks
Nick
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to