You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Anthony Buck <ro...@arbia.co.uk> on 2010/09/08 23:09:38 UTC
URLs
Hi All,
I am checking out click as a possible contender for some work I am
doing, but I have a little query. Is it possible to have click use path
based url's instead of query based ones?
i.e.
http://domain.com/text-demo.htm?actionLink=update
becomes:
http://domain.com/text-demo/update
I know it's a long-shot but this would really make a difference.
Regards,
Re: URLs
Posted by Bob Schellink <sa...@gmail.com>.
Maybe we can put together a wiki[1] page with rewrite rules for the various urls rendered by Click.
These will be for Form, various AbstractLink subclasses and the Page template URLs.
URLRewriteFilter also includes support for a custom Java class that can be used to encapsulate these
rules instead of XML.
Bob
[1]: https://cwiki.apache.org/confluence/display/CLICK/Index
On 12/09/2010 19:34, Axel Morgner wrote:
> Maybe URLRewriteFilter with something like
>
> <outbound-rule>
> <from>/text-demo.htm\?actionLink=(.*)&(.*)</from>
> <to>/text-demo/$1?$2</to>
> </outbound-rule>
>
> works for you.
>
> Regards
>
> Axel
>
> Am 11.09.2010 23:46, schrieb Domain Admin:
>> Can something like this be done for link generation within the pages as well?
>>
>> Sent from my iPhone
>>
>> On 11 Sep 2010, at 09:49, "Adrian A." <a....@gmail.com> wrote:
>>
>>>> I am checking out click as a possible contender for some work I am
>>>> doing, but I have a little query. Is it possible to have click use path
>>>> based url's instead of query based ones?
>>>>
>>>> i.e.
>>>> http://domain.com/text-demo.htm?actionLink=update
>>>>
>>>> becomes:
>>>>
>>>> http://domain.com/text-demo/update
>>>>
>>>> I know it's a long-shot but this would really make a difference.
>>> If you use Apache HTTPD in front of your Tomcat instance, than you can activate mod_rewrite to do this for you (this is how many projects do it: e.g. all PHP based too).
>>> For other servers there are similar modules for rewriting.
>>>
>>> If you use purely Java for your servers than, as Bob already answered,
>>> you can use URLRewriteFilter.
>>> This is already explained in the Click FAQ:
>>> http://click.apache.org/docs/faq.html#alternative-extension
>>>
>>> If you don't want to use URLRewriteFilter, than you can do the rewriting quite simply with a ServletFilter:
>>> - Create a custom ServletFilter that will call an:
>>> - Extended by you javax.servlet.http.HttpServletResponseWrapper
>>> and a
>>> javax.servlet.http.HttpServletResponseWrapper
>>> In these two wrapper classes you can directly modify/manipulate the URLs(and of course practically the entire request or response) at your wish.
>>>
>>> Adrian.
>>>
>
>
>
Re: URLs
Posted by Axel Morgner <ax...@morgner.de>.
Maybe URLRewriteFilter with something like
<outbound-rule>
<from>/text-demo.htm\?actionLink=(.*)&(.*)</from>
<to>/text-demo/$1?$2</to>
</outbound-rule>
works for you.
Regards
Axel
Am 11.09.2010 23:46, schrieb Domain Admin:
> Can something like this be done for link generation within the pages as well?
>
> Sent from my iPhone
>
> On 11 Sep 2010, at 09:49, "Adrian A." <a....@gmail.com> wrote:
>
>>> I am checking out click as a possible contender for some work I am
>>> doing, but I have a little query. Is it possible to have click use path
>>> based url's instead of query based ones?
>>>
>>> i.e.
>>> http://domain.com/text-demo.htm?actionLink=update
>>>
>>> becomes:
>>>
>>> http://domain.com/text-demo/update
>>>
>>> I know it's a long-shot but this would really make a difference.
>> If you use Apache HTTPD in front of your Tomcat instance, than you can activate mod_rewrite to do this for you (this is how many projects do it: e.g. all PHP based too).
>> For other servers there are similar modules for rewriting.
>>
>> If you use purely Java for your servers than, as Bob already answered,
>> you can use URLRewriteFilter.
>> This is already explained in the Click FAQ:
>> http://click.apache.org/docs/faq.html#alternative-extension
>>
>> If you don't want to use URLRewriteFilter, than you can do the rewriting quite simply with a ServletFilter:
>> - Create a custom ServletFilter that will call an:
>> - Extended by you javax.servlet.http.HttpServletResponseWrapper
>> and a
>> javax.servlet.http.HttpServletResponseWrapper
>> In these two wrapper classes you can directly modify/manipulate the URLs(and of course practically the entire request or response) at your wish.
>>
>> Adrian.
>>
Re: URLs
Posted by Bob Schellink <sa...@gmail.com>.
Not sure I understand the question fully, but I suspect the answer is no.
Kind regards
Bob
On Sun, Sep 12, 2010 at 7:46 AM, Domain Admin <ro...@arbia.co.uk> wrote:
> Can something like this be done for link generation within the pages as well?
>
> Sent from my iPhone
>
> On 11 Sep 2010, at 09:49, "Adrian A." <a....@gmail.com> wrote:
>
>>> I am checking out click as a possible contender for some work I am
>>> doing, but I have a little query. Is it possible to have click use path
>>> based url's instead of query based ones?
>>>
>>> i.e.
>>> http://domain.com/text-demo.htm?actionLink=update
>>>
>>> becomes:
>>>
>>> http://domain.com/text-demo/update
>>>
>>> I know it's a long-shot but this would really make a difference.
>> If you use Apache HTTPD in front of your Tomcat instance, than you can activate mod_rewrite to do this for you (this is how many projects do it: e.g. all PHP based too).
>> For other servers there are similar modules for rewriting.
>>
>> If you use purely Java for your servers than, as Bob already answered,
>> you can use URLRewriteFilter.
>> This is already explained in the Click FAQ:
>> http://click.apache.org/docs/faq.html#alternative-extension
>>
>> If you don't want to use URLRewriteFilter, than you can do the rewriting quite simply with a ServletFilter:
>> - Create a custom ServletFilter that will call an:
>> - Extended by you javax.servlet.http.HttpServletResponseWrapper
>> and a
>> javax.servlet.http.HttpServletResponseWrapper
>> In these two wrapper classes you can directly modify/manipulate the URLs(and of course practically the entire request or response) at your wish.
>>
>> Adrian.
>>
>
Re: URLs
Posted by Bob Schellink <sa...@gmail.com>.
On 12/09/2010 19:46, Adrian A. wrote:
> I think it might be a great addition if somehow it would be easy
> for the user(developer) to just "map" this behavior(URLs and the verbs) over a Click application too
> (or at least over a part of the application):
> - nowadays many webapps are required to expose a "public" API for a part of their functionality,
> and that in a REST like style.
Thinking about this today I'm not sure it makes sense. REST is a way to expose services on the web.
Click is a view framework and could consume those REST services, but being itself consumed used as
REST services will probably lead to a conflict of interest.
Bob
Re: URLs
Posted by Bob Schellink <sa...@gmail.com>.
My point is that we should differentiate between RESTFUL URLs
(qwhatever that means) and "Pretty URLs" or as Anthony called it "Path
based URLs". I cannot find where REST states URLs must be path based,
and I don't think it does.
Bob
Re: URLs
Posted by "Adrian A." <a....@gmail.com>.
>> Practically this is how most (e.g. PHP) frameworks use mod_rewrite to hide
>> their implementation, or just offer a REST like URL structure.
>
> I'm curious. Is there a reference where the RESTFUL URL structure is
> defined?
Unfortunately I can't find a single good source for it :(. The following
presentation is quite nice:
http://www.slideshare.net/Wombert/designing-url-schemes-and-rest-interfaces
(especially slide 43 and 44).
And an interesting list of dos and don'ts:
http://stackoverflow.com/questions/1619152/how-to-create-rest-urls-without-verbs/1619677#1619677
> From what I can tell Click URLs are RESTFUL,
I guess they are only "RESTful(able)".
They don't follow the usual REST URL pattern:
- no extension (only mime type)
- less query strings in the form *page.htm?param1=value1 but values
separated by slashes *page/param1/value1 (using query strings only for
filtering).
It shouldn't be that complicated for ServletFilter placed just before
the compression filter to make Click have this type of URL scheme.
Personally I like having URL extensions (when I see an URL without an
extension, my first thought is still that it's a directory :) ).
> but Click is not
> a REST based framework (PUT, DELETE, READ etc).
I think it might be a great addition if somehow it would be easy
for the user(developer) to just "map" this behavior(URLs and the verbs)
over a Click application too (or at least over a part of the application):
- nowadays many webapps are required to expose a "public" API for a
part of their functionality, and that in a REST like style.
Adrian.
Re: URLs
Posted by Bob Schellink <sa...@gmail.com>.
On Sun, Sep 12, 2010 at 8:44 AM, Adrian A. <a....@gmail.com> wrote:
>
> Practically this is how most (e.g. PHP) frameworks use mod_rewrite to hide
> their implementation, or just offer a REST like URL structure.
I'm curious. Is there a reference where the RESTFUL URL structure is
defined? From what I can tell Click URLs are RESTFUL, but Click is not
a REST based framework (PUT, DELETE, READ etc).
Bob
Re: URLs
Posted by "Adrian A." <a....@gmail.com>.
> Can something like this be done for link generation within the pages as well?
From the wrappers you have full control over the content too, so you can
rewrite the "href" attributes of links too, supposed these attributes
are "static", i.e. you don't create them dynamically in the browser with
some JavaScript concatenation trick.
Practically this is how most (e.g. PHP) frameworks use mod_rewrite to
hide their implementation, or just offer a REST like URL structure.
Adrian.
Re: URLs
Posted by Domain Admin <ro...@arbia.co.uk>.
Can something like this be done for link generation within the pages as well?
Sent from my iPhone
On 11 Sep 2010, at 09:49, "Adrian A." <a....@gmail.com> wrote:
>> I am checking out click as a possible contender for some work I am
>> doing, but I have a little query. Is it possible to have click use path
>> based url's instead of query based ones?
>>
>> i.e.
>> http://domain.com/text-demo.htm?actionLink=update
>>
>> becomes:
>>
>> http://domain.com/text-demo/update
>>
>> I know it's a long-shot but this would really make a difference.
> If you use Apache HTTPD in front of your Tomcat instance, than you can activate mod_rewrite to do this for you (this is how many projects do it: e.g. all PHP based too).
> For other servers there are similar modules for rewriting.
>
> If you use purely Java for your servers than, as Bob already answered,
> you can use URLRewriteFilter.
> This is already explained in the Click FAQ:
> http://click.apache.org/docs/faq.html#alternative-extension
>
> If you don't want to use URLRewriteFilter, than you can do the rewriting quite simply with a ServletFilter:
> - Create a custom ServletFilter that will call an:
> - Extended by you javax.servlet.http.HttpServletResponseWrapper
> and a
> javax.servlet.http.HttpServletResponseWrapper
> In these two wrapper classes you can directly modify/manipulate the URLs(and of course practically the entire request or response) at your wish.
>
> Adrian.
>
Re: URLs
Posted by "Adrian A." <a....@gmail.com>.
> I am checking out click as a possible contender for some work I am
> doing, but I have a little query. Is it possible to have click use path
> based url's instead of query based ones?
>
> i.e.
> http://domain.com/text-demo.htm?actionLink=update
>
> becomes:
>
> http://domain.com/text-demo/update
>
> I know it's a long-shot but this would really make a difference.
If you use Apache HTTPD in front of your Tomcat instance, than you can
activate mod_rewrite to do this for you (this is how many projects do
it: e.g. all PHP based too).
For other servers there are similar modules for rewriting.
If you use purely Java for your servers than, as Bob already answered,
you can use URLRewriteFilter.
This is already explained in the Click FAQ:
http://click.apache.org/docs/faq.html#alternative-extension
If you don't want to use URLRewriteFilter, than you can do the rewriting
quite simply with a ServletFilter:
- Create a custom ServletFilter that will call an:
- Extended by you javax.servlet.http.HttpServletResponseWrapper
and a
javax.servlet.http.HttpServletResponseWrapper
In these two wrapper classes you can directly modify/manipulate the
URLs(and of course practically the entire request or response) at your wish.
Adrian.
Re: URLs
Posted by Bob Schellink <sa...@gmail.com>.
Hi Anthony,
No, but since Click is stateless. URLs are bookmarkable so you could
use URLRewriteFilter[1] to rewrite them.
Kind regards
Bob
[1]: http://www.tuckey.org/urlrewrite/
On Thu, Sep 9, 2010 at 7:09 AM, Anthony Buck <ro...@arbia.co.uk> wrote:
> Hi All,
> I am checking out click as a possible contender for some work I am
> doing, but I have a little query. Is it possible to have click use path
> based url's instead of query based ones?
> i.e.
> http://domain.com/text-demo.htm?actionLink=update
> becomes:
> http://domain.com/text-demo/update
> I know it's a long-shot but this would really make a difference.
> Regards,