Devin Rhode
Devin Rhode

Reputation: 25267

Get headers in grails view

I am trying to get the User Agent header in a grails partial, and if the User Agent is Chrome, display a notification to download a chrome extension.

This is some code of mine that fails to achieve this:

<% def useragent = request.getHeader("User Agent") %>
${useragent + 'asdf'} 

Upvotes: 2

Views: 3116

Answers (2)

mikedave
mikedave

Reputation: 350

Rather than writing your own you could also consider something like what Kevin Gill did.

Upvotes: 1

tim_yates
tim_yates

Reputation: 171054

Shouldn't that be:

<% def useragent = request.getHeader("User-Agent") %>

With a hyphen?

Upvotes: 6

Related Questions