Re: T5 Handling invalid urls with redirects
A quick and easy solution is to implement a request filter in Tapestry and then add some checks for path errors that you are expecting. An example: public class PagePathChecker implements RequestFilter { /** * The globals Tapestry service */ private ApplicationGlobals globals_; public boolean service(Request request, Response response, RequestHandler handler) throws IOException { String servletRoot = globals_.getServletContext().getContextPath(); String path = correctPath(request.getPath()); boolean pathFault = (path.equalsIgnoreCase(request.getPath())) ? false : true; // correction for known paths that produce 404 errors if (pathFault) { response.sendRedirect(servletRoot + path); return true; } return handler.service(request, response); } private String correctPath(String path) { if (path.equalsIgnoreCase(/index.jsp) || path.equalsIgnoreCase(/index.html)) { return /index; } return path; } } Of course you would need to test this. cheers Peter - Original Message - From: Martin Strand [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Tuesday, 21 October, 2008 12:10:34 AM GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: Re: T5 Handling invalid urls with redirects We switched from PHP to Tapestry last year and I'm using a rewrite filter to redirect old urls to the new ones: http://tuckey.org/urlrewrite/ Martin On Mon, 20 Oct 2008 22:05:38 +0200, nillehammer [EMAIL PROTECTED] wrote: Hi List, Long time no see. I have finally got my application online and am facing two problems, I have not thought of before. Both of which are users or search bots (namely google) using wrong urls. 1.) I have got an index Page in the root which works fine, but my beloved users tend to type index.jsp or index.html instead of just index into the address bar of their browser. (Maybe it's because they're mainly Germans and therefore are hyper correct;-)) ) The dot being used Tapestry interprets those as components on the index page with ids jsp and html and shows my nicely crafted ExceptionReport. I'd rather have Tapestry send a redirect to the correct url. How can this be accomplished? I have thought of implementing components with names jsp and html and writing event handlers for them but that seems a bit odd to me. 2.) Before the migration to Tapestry the application was struts based. Therefore all the URLs within the application have changed. That would not be a problem, but google keeps the old URLs. I think the reason is that when a completely wrong URL is typed in Tapestry will directly response with the index page rather than redirecting to it. So the client-software never gets informed about the incorrectness. Also in this case I would like Tapestry to do a redirect. How can this be done? Your help will be apreciated. Yours nillehammer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5 Handling invalid urls with redirects
Hi List, Long time no see. I have finally got my application online and am facing two problems, I have not thought of before. Both of which are users or search bots (namely google) using wrong urls. 1.) I have got an index Page in the root which works fine, but my beloved users tend to type index.jsp or index.html instead of just index into the address bar of their browser. (Maybe it's because they're mainly Germans and therefore are hyper correct;-)) ) The dot being used Tapestry interprets those as components on the index page with ids jsp and html and shows my nicely crafted ExceptionReport. I'd rather have Tapestry send a redirect to the correct url. How can this be accomplished? I have thought of implementing components with names jsp and html and writing event handlers for them but that seems a bit odd to me. 2.) Before the migration to Tapestry the application was struts based. Therefore all the URLs within the application have changed. That would not be a problem, but google keeps the old URLs. I think the reason is that when a completely wrong URL is typed in Tapestry will directly response with the index page rather than redirecting to it. So the client-software never gets informed about the incorrectness. Also in this case I would like Tapestry to do a redirect. How can this be done? Your help will be apreciated. Yours nillehammer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 Handling invalid urls with redirects
We switched from PHP to Tapestry last year and I'm using a rewrite filter to redirect old urls to the new ones: http://tuckey.org/urlrewrite/ Martin On Mon, 20 Oct 2008 22:05:38 +0200, nillehammer [EMAIL PROTECTED] wrote: Hi List, Long time no see. I have finally got my application online and am facing two problems, I have not thought of before. Both of which are users or search bots (namely google) using wrong urls. 1.) I have got an index Page in the root which works fine, but my beloved users tend to type index.jsp or index.html instead of just index into the address bar of their browser. (Maybe it's because they're mainly Germans and therefore are hyper correct;-)) ) The dot being used Tapestry interprets those as components on the index page with ids jsp and html and shows my nicely crafted ExceptionReport. I'd rather have Tapestry send a redirect to the correct url. How can this be accomplished? I have thought of implementing components with names jsp and html and writing event handlers for them but that seems a bit odd to me. 2.) Before the migration to Tapestry the application was struts based. Therefore all the URLs within the application have changed. That would not be a problem, but google keeps the old URLs. I think the reason is that when a completely wrong URL is typed in Tapestry will directly response with the index page rather than redirecting to it. So the client-software never gets informed about the incorrectness. Also in this case I would like Tapestry to do a redirect. How can this be done? Your help will be apreciated. Yours nillehammer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]