string useragent = request.getheader("user-agent"); system.out.println("useragent:"+useragent); useragent=useragent.tolowercase(); //convert to lowercase and then check if(useragent.indexof("netscape6") != -1) { system.out.println("netscape"); } else if(useragent.indexof("msie") != -1) { system.out.println("ie"); } else if(useragent.indexof("firefox") != -1) { system.out.println("firefox"); } else if(useragent.indexof("safari") != -1) { system.out.println("safari"); } else { system.out.println("else"); }