You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Cedric Puchalver <ce...@season-of-mist.com> on 2013/03/01 11:47:42 UTC
http referer variable
Hi,
I'm new to velocity. In my company we are using a webapp (OpenEMM -
http://www.openemm.org) to handle our mailing campaigns and this app is
using velocity 1.4.
We have two websites and we set a single form to subscribe to two
different mailing-lists, one for each website... I want to use a
different css in our form based on the http referer header.
Here what I've tried with no avail :
#set($referer = $request.getHeader('Referer')
#if($referer =="http://www.domain1.com")
<link href="http://www.domain1.com/style.css" media="all" rel="stylesheet" type="text/css" />
#elseif($referer =="http://www.domain2.com")
<link href="http://www.domain2.com/style.css" media="all" rel="stylesheet" type="text/css" />
#end
Here the output in the velocity log :
org.apache.velocity.runtime.exception.ReferenceException: reference : template = null : $referer is not a valid reference.
Any idea of what's going wrong?
Thanks,
Cedric
--
General season signature
*Cedric Puchalver*
111, Route de la Valentine, lot n° 11
13011 Marseille
France
Phone +33 [0]4 86 778 125
Fax +33 [0]4 91 80 00 37
www.season-of-mist.com <http://www.season-of-mist.com>
*Please conserve paper / print only if necessary*
Season of Mist banner <http://www.season-of-mist.com>
*Important:* This e-mail may contain confidential information. If you
are not the intended recipient it may be unlawful for you to read, copy,
distribute, disclose or otherwise use information contained in it. If
this is the case, please contact us immediately by e-mail : Reply to sender.
Errors and omissions may occur in the contents of this e-mail. The
sender accepts no responsibility for any such errors or omissions, and
you are advised to confirm the accuracy of its contents before relying
on it for any purpose.
To the extent that this e-mail is not an official communication of the
Company, the sender is acting neither as an agent, representative nor in
any other capacity for or on behalf of the Company.
Re: http referer variable
Posted by Claude Brisson <cl...@renegat.net>.
Velocity itself is only a template engine, and doesn't know anything
about HTTP requests or responses. It does need some wrapper to have it
work in a web context.
If you are using Velocity 1.4 (quite an old version, by the way),
there are some chances that the wrapper is VelocityServlet, in which
case the key to access the request is "req".
Claude
On Fri, 01 Mar 2013 14:00:43 +0100
Cedric Puchalver <ce...@season-of-mist.com> wrote:
> Hi Claude,
>
> Thanks for your answer.
>
> The missing closing paarenthesis is indeed a copy/paste mistake.
> About the variable $request, I thought it was somehow already defined
> in velocity, which it seems not to be the case because it's not
> interpreted by the server and the forms simply displays $request.
>
> Do you have any idea of how to get the http_referer header?
>
> Regards,
> Cedric
>
> Le 01/03/2013 13:06, Claude Brisson a écrit :
> > There is a missing closing parenthesis in the first line of your
> > code. But maybe it's only a side effect of the copy paste and not
> > the source of the problem.
> >
> > Id you check that $request was defined? What happens if you try to
> > display it for debugging purposes?
> >
> >
> > Claude
> >
> >
> > On Fri, 01 Mar 2013 11:47:42 +0100
> > Cedric Puchalver <ce...@season-of-mist.com> wrote:
> >
> >> Hi,
> >>
> >> I'm new to velocity. In my company we are using a webapp (OpenEMM -
> >> http://www.openemm.org) to handle our mailing campaigns and this
> >> app is using velocity 1.4.
> >>
> >> We have two websites and we set a single form to subscribe to two
> >> different mailing-lists, one for each website... I want to use a
> >> different css in our form based on the http referer header.
> >>
> >> Here what I've tried with no avail :
> >>
> >> #set($referer = $request.getHeader('Referer')
> >> #if($referer =="http://www.domain1.com")
> >> <link href="http://www.domain1.com/style.css" media="all"
> >> rel="stylesheet" type="text/css" /> #elseif($referer
> >> =="http://www.domain2.com") <link
> >> href="http://www.domain2.com/style.css" media="all"
> >> rel="stylesheet" type="text/css" /> #end
> >>
> >> Here the output in the velocity log :
> >>
> >> org.apache.velocity.runtime.exception.ReferenceException:
> >> reference : template = null : $referer is not a valid reference.
> >>
> >> Any idea of what's going wrong?
> >>
> >> Thanks,
> >> Cedric
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: http referer variable
Posted by Cedric Puchalver <ce...@season-of-mist.com>.
Hi Claude,
Thanks for your answer.
The missing closing paarenthesis is indeed a copy/paste mistake.
About the variable $request, I thought it was somehow already defined in
velocity, which it seems not to be the case because it's not interpreted
by the server and the forms simply displays $request.
Do you have any idea of how to get the http_referer header?
Regards,
Cedric
Le 01/03/2013 13:06, Claude Brisson a écrit :
> There is a missing closing parenthesis in the first line of your code.
> But maybe it's only a side effect of the copy paste and not the source
> of the problem.
>
> Id you check that $request was defined? What happens if you try to
> display it for debugging purposes?
>
>
> Claude
>
>
> On Fri, 01 Mar 2013 11:47:42 +0100
> Cedric Puchalver <ce...@season-of-mist.com> wrote:
>
>> Hi,
>>
>> I'm new to velocity. In my company we are using a webapp (OpenEMM -
>> http://www.openemm.org) to handle our mailing campaigns and this app
>> is using velocity 1.4.
>>
>> We have two websites and we set a single form to subscribe to two
>> different mailing-lists, one for each website... I want to use a
>> different css in our form based on the http referer header.
>>
>> Here what I've tried with no avail :
>>
>> #set($referer = $request.getHeader('Referer')
>> #if($referer =="http://www.domain1.com")
>> <link href="http://www.domain1.com/style.css" media="all"
>> rel="stylesheet" type="text/css" /> #elseif($referer
>> =="http://www.domain2.com") <link
>> href="http://www.domain2.com/style.css" media="all" rel="stylesheet"
>> type="text/css" /> #end
>>
>> Here the output in the velocity log :
>>
>> org.apache.velocity.runtime.exception.ReferenceException: reference :
>> template = null : $referer is not a valid reference.
>>
>> Any idea of what's going wrong?
>>
>> Thanks,
>> Cedric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: http referer variable
Posted by Claude Brisson <cl...@renegat.net>.
There is a missing closing parenthesis in the first line of your code.
But maybe it's only a side effect of the copy paste and not the source
of the problem.
Id you check that $request was defined? What happens if you try to
display it for debugging purposes?
Claude
On Fri, 01 Mar 2013 11:47:42 +0100
Cedric Puchalver <ce...@season-of-mist.com> wrote:
> Hi,
>
> I'm new to velocity. In my company we are using a webapp (OpenEMM -
> http://www.openemm.org) to handle our mailing campaigns and this app
> is using velocity 1.4.
>
> We have two websites and we set a single form to subscribe to two
> different mailing-lists, one for each website... I want to use a
> different css in our form based on the http referer header.
>
> Here what I've tried with no avail :
>
> #set($referer = $request.getHeader('Referer')
> #if($referer =="http://www.domain1.com")
> <link href="http://www.domain1.com/style.css" media="all"
> rel="stylesheet" type="text/css" /> #elseif($referer
> =="http://www.domain2.com") <link
> href="http://www.domain2.com/style.css" media="all" rel="stylesheet"
> type="text/css" /> #end
>
> Here the output in the velocity log :
>
> org.apache.velocity.runtime.exception.ReferenceException: reference :
> template = null : $referer is not a valid reference.
>
> Any idea of what's going wrong?
>
> Thanks,
> Cedric
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org