Possible Duplicate:
How can I get client infomation such as OS and browser
i want to know clients machine Operating system name when i received request in my servlet
through request
object
thanks in advance
Possible Duplicate:
How can I get client infomation such as OS and browser
i want to know clients machine Operating system name when i received request in my servlet
through request
object
thanks in advance
Example using the user-agent-utils library:
public class SomeServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String userAgentString = request.getHeader("User-Agent");
UserAgent userAgent = UserAgent.parseUserAgentString(userAgentString);
OperatingSystem os = userAgent.getOperatingSystem();
// Do stuff with os...
}
}
You can read more about the OperatingSystem class here.
You can find the jar here.
Use user-agent HTTP header. Here is how it looks like on my machine:
user-agent Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
As you can see it is a freely formatted text, so you have to investigate different user agent and process them using probably regular expression.