David Leangen wrote:
Thanks, Kent.
Since I need this, I will gladly code it in Java and contribute it back to
the Tapestry project.
However, before I begin... does anybody already have a Java class that does
this, so I don't have to reinvent the wheel?
Here's one I used on a project a couple of years ago:
public final class DetectBrowser implements Serializable {
private HttpServletRequest request = null;
private String useragent = null;
private boolean netEnabled = false;
private boolean ie = false;
private boolean ns = false;
private boolean mac = false;
private boolean win = false;
public void setRequest(HttpServletRequest req)
{
request = req;
useragent = request.getHeader("User-Agent");
String user = useragent.toLowerCase();
if (user.indexOf("msie") != -1) {
ie = true;
} else if (user.indexOf("gecko") != -1) {
ns = true;
}
if (user.indexOf("mac") != -1) {
mac = true;
}
}
public String getUseragent()
{
return useragent;
}
public boolean isNetEnabled()
{
return netEnabled;
}
public boolean isIE()
{
return ie;
}
public boolean isNS()
{
return ns;
}
public boolean isMac()
{
return mac;
}
}
Thanks!
Dave
-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] Behalf Of Kent Tong
Sent: 12 April 2005 11:22
To: [email protected]
Subject: Re: Browser detection component?
David Leangen <dleangen <at> canada.com> writes:
Anybody know where I can find a browser detection component?
I'm unaware of any such component, but you can get a
javascript to do that at
http://www.dithered.com/javascript/browser_detect/browser_detect.txt
If you'd like, you can convert it to a component. However,
as it is not generating any html code, it doesn't look
like a good candidate for a component to me. I'd code it
in a Java class (eg, BrowserDetector.java).
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]