Issue:
How to read HTTP Header parameters using JSF?
Solution:
Reading the http headers parameters in JSF is possible using the ExternalContext.
This class allows the Faces API to be unaware of the nature of its containing application environment. In particular, this class allows JavaServer Faces based appications to run in either a Servlet or a Portlet environment.
The Method getRequestHeaderMap provide to get a read only java.util.Map that contains all the http parameters. Follow how to read all the the parameters into the http header:
FacesContext fc = FacesContext.getCurrentInstance();
Map<String,String> map = fc.getExternalContext().getRequestHeaderMap();
for(Object o : map.keySet().toArray()){
String tmp = o+": "+map.get(o);
System.out.println(tmp);
}
No comments:
Post a Comment