PDA

View Full Version : RubyOnRails-Style URL Patterns



moseph
May 11th, 2006, 11:21 PM
Anyone have a solution on how to set-up the pattern matching similar to RubyOnRails so that an object ID gets passed in through the request path?

Example: (where ID = 123)

/app/123/home
/app/123/reports
/app/123/reports?subaccount=101&....

So 123 would implicitly be bound to a request variable..

Interceptors might be helpful? How can I configure the URL pattern mappings? They would need to ignore the ID portion...

Thanks!!!!!!!

manifoldronin
May 12th, 2006, 12:02 AM
If you run Apache upfront, you can use its url rewriting, which doesn't have anything to do with whatever j2ee container sitting behind.
If you are running a container directly, try out UrlRewriteFilter (http://tuckey.org/urlrewrite/). I have never actually used it though.

Colin Yates
May 12th, 2006, 04:17 AM
Hmmm, without really thinking this through, I might have a filter which took a special pattern to identify all the parameters and converted them into request parameters.

So one filter might be configured with the following "/*/id/*". The controller would then need to be mapped to "/app/*/home" and hopefully the filter would have populated the "id" parameter...

A bit fragile ... Apache rewriting is certainly a better choice :)