Wed Oct 22, 2008 2:04 am
Wed Oct 22, 2008 2:04 am
String browserType=(String)request.getHeader("User-Agent");
now if you print browserType , you will get the information of browser.
Fri Oct 23, 2009 5:25 am
private String getBrowserType(String currValue){
String browser = new String("");
String version = new String("");
if(currValue != null ){
if((currValue.indexOf("MSIE") == -1) && (currValue.indexOf("msie") == -1)){
browser = "NS";
int verPos = currValue.indexOf("/");
if(verPos != -1)
version = currValue.substring(verPos+1,verPos + 5);
}
else{
browser = "IE";
String tempStr = currValue.substring(currValue.indexOf("MSIE"),currValue.length());
version = tempStr.substring(4,tempStr.indexOf(";"));
}
}
System.out.println(" now browser type is " + browser +" " + version);
return browser + " " + version;
}
Mon Nov 02, 2009 1:57 pm
String browserType = request.getHeader("User-Agent");
<%=request.getHeader("user-agent")%>
<%=request.getRemoteAddr()%>
<%
String userAgent = request.getHeader("user-agent");
if (userAgent.indexOf("MSIE") > -1) {
out.println("Your browser is Microsoft Internet Explorer<br/>");
}
Mon Nov 02, 2009 3:15 pm
Tue Sep 27, 2011 11:25 am
<%!
public String getBrowserInfo( String Information )
{
String browsername = "";
String browserversion = "";
String browser = Information ;
if(browser.contains("MSIE")){
String subsString = browser.substring( browser.indexOf("MSIE"));
String Info[] = (subsString.split(";")[0]).split(" ");
browsername = Info[0];
browserversion = Info[1];
}
else if(browser.contains("Firefox")){
String subsString = browser.substring( browser.indexOf("Firefox"));
String Info[] = (subsString.split(" ")[0]).split("/");
browsername = Info[0];
browserversion = Info[1];
}
else if(browser.contains("Chrome")){
String subsString = browser.substring( browser.indexOf("Chrome"));
String Info[] = (subsString.split(" ")[0]).split("/");
browsername = Info[0];
browserversion = Info[1];
}
else if(browser.contains("Opera")){
String subsString = browser.substring( browser.indexOf("Opera"));
String Info[] = (subsString.split(" ")[0]).split("/");
browsername = Info[0];
browserversion = Info[1];
}
else if(browser.contains("Safari")){
String subsString = browser.substring( browser.indexOf("Safari"));
String Info[] = (subsString.split(" ")[0]).split("/");
browsername = Info[0];
browserversion = Info[1];
}
return browsername + "-" +browserversion;
}
%>
<% out.println(getBrowserInfo(request.getHeader("User-Agent")));%>
Fri Oct 14, 2011 3:33 pm
Sat Jan 12, 2013 6:32 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.