|
Re: URL Rewriting and Velocity: msg#00234jakarta.velocity.user
What I do for Url rewriting directly in my templates is to add a handful of helper macros to the VM_global_library.vm (see below) and then ensure I always put the Servlet HttpResponse in the Velocity context under the name "response". So when I need to rewrite an Url I just have to use the functions #Url, #QuotedUrl, #Redirect and #QuotedRedirect - see the doc... The VM_global_library.vm snippet: ## ## macro: Url ## ## parameters: $url ## ## description: Encodes a link with servlet session information ## ## prerequisite: Servlet response required to be placed in the ## context as 'response'. ## ## html use: <a href="#Url($link)">My link</a> ## ## July 2002, martin@xxxxxxxxxxxxxxxx ## #macro( Url $url ) $response.encodeURL($url)#end ## ## macro: QuotedUrl ## ## parameters: $url ## ## description: Encodes a link with servlet session information and ## adds surrounding quotes. ## ## prerequisite: Servlet response required to be placed in the ## context as 'response'. ## ## html use: <a href=#Url($link)>My link</a> ## ## July 2002, martin@xxxxxxxxxxxxxxxx ## #macro( QuotedUrl $url ) "$response.encodeURL($url)"#end ## ## macro: Redirect ## ## parameters: $url ## ## description: Encodes a redirect with servlet session information. ## ## prerequisite: Servlet response required to be placed in the ## context as 'response'. ## ## html use: <a href=#Url($link)>My link</a> ## ## July 2002, martin@xxxxxxxxxxxxxxxx ## #macro( Redirect $url ) $response.encodeRedirectURL($url)#end ## ## macro: QuotedRedirect ## ## parameters: $url ## ## description: Encodes a redirect with servlet session information and ## adds surrounding quotes. ## ## prerequisite: Servlet response required to be placed in the ## context as 'response'. ## ## html use: <a href=#Url($link)>My link</a> ## ## July 2002, martin@xxxxxxxxxxxxxxxx ## #macro( QuotedRedirect $url ) "$response.encodeRedirectURL($url)"#end *********** REPLY SEPARATOR *********** On 11/29/2002 at 18:29 Kwirirai wrote: >Hi >My question is does Velocity support URL Rewriting or I have to employ URL >rewriting with my own >Implementation. I know that with Servlets you can do URL Rewriting while >printing out to the client. Since velocity >Does the printing out ,how can URL Rewriting be done using velocity. > >kwiri > > >-- >To unsubscribe, e-mail: ><mailto:velocity-user-unsubscribe@xxxxxxxxxxxxxxxxxx> >For additional commands, e-mail: <mailto:velocity-user-help@xxxxxxxxxxxxxxxxxx> |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: URL Rewriting and Velocity: 00234, Geir Magnusson Jr . |
|---|---|
| Next by Date: | [ANN] vDoclet-20021128 released: 00234, Mike Williams |
| Previous by Thread: | Re: URL Rewriting and Velocityi: 00234, Geir Magnusson Jr . |
| Next by Thread: | [ANN] vDoclet-20021128 released: 00234, Mike Williams |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |