Dave's Brain

Browse - Programming Tips - In a Java Servlet, how can I check if the browser is Firefox?

Date: 2012oct12
Language: Java

Q.  In a Java Servlet, how can I check if the browser is Firefox?

A.  Here's a method that does that:

boolean isFirefox(HttpServeletRequest req) { final String agent = req.getHeader("User-Agent"); if (agent == null) return false; return agent.indexOf("Firefox") >= 0; }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.