Re: http referer variable

Claude Brisson <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <20130301130601.535fcfee@emc>
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 <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.