Get Request Headers in a JSF Backing Bean
In your backing bean use the following:
final HttpServletRequest request = (HttpServletRequest) FacesContext
.getCurrentInstance().getExternalContext().getRequest();
final Enumeration<String> keys = request.getHeaderNames();
while (keys.hasMoreElements()) {
final String key = keys.nextElement();
final String val = request.getHeader(key);
System.out.println(key + " : " + val);
}
The result could be something like this:
host : localhost:8080
user-agent : Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0
accept : text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
accept-language : de-de,de;q=0.8,en;q=0.5,en-us;q=0.3
accept-encoding : gzip, deflate
dnt : 1
connection : keep-alive
content-type : application/x-www-form-urlencoded; charset=utf-8
faces-request : partial/ajax
referer : http://localhost:8080/Project/html/foo.xhtml
content-length : 449
cookie : JSESSIONID=QW3ER6TZUIO0P9L8K7J6H5G4F3D2S1AY; oam.Flash.RENDERMAP.TOKEN=qn6g3o1sm
pragma : no-cache
cache-control : no-cache