Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check User-Agent with jsf

Tags:

jsf

user-agent

I want to check the user agent of my client. (If it's possible the browser type/version)

But I don't know how do that...

Thank you for your help.

like image 446
Akabane Avatar asked Dec 02 '22 00:12

Akabane


2 Answers

It is OK, I have find. I use :

final HttpServletRequest request =(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
final String userAgent = request.getHeader("user-agent");
System.out.println(userAgent);

Thank you for your help.

like image 94
Akabane Avatar answered Feb 08 '23 23:02

Akabane


It is sent in the User-Agent http header.

HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
String userAgent = request.getHeader("user-agent");
like image 23
ThiefMaster Avatar answered Feb 08 '23 22:02

ThiefMaster