Referencing HTTP headers in a Freemarker template

Managed by | Updated .


This article explains how to access HTTP headers from within a Freemarker template.


The data model includes a hidden httpRequest object that can be referenced from with Freemarker templates.

The following code reads a custom http header attribute (X-Funnelback-form) and uses this as a condition within an if statement:

<#ftl encoding="utf-8" />
<#import "/web/templates/modernui/funnelback_classic.ftl" as s/>
<#import "/web/templates/modernui/funnelback.ftl" as fb/>
<html lang="en">
         <#assign  mtype=httpRequest.getHeader('X-Funnelback-form')>
         <#if mtype == "mobile">
             <#include "simple-mobile.ftl">
             <#include "simple-basic.ftl">
Was this artcle helpful?

Type: Keywords:
Features: Frontend > Modern UI Frontend > Freemarker