Reputation: 25267
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
Reputation: 350
Rather than writing your own you could also consider something like what Kevin Gill did.
Upvotes: 1
Reputation: 171054
Shouldn't that be:
<% def useragent = request.getHeader("User-Agent") %>
With a hyphen?
Upvotes: 6