String refText = request.getHeader("referer");
if (refText == null) {
// no referer
}
-----Original Message-----
From: John M. Corro [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 9:11 AM
To: [EMAIL PROTECTED]
Subject: Best way to find referrer
I'm looking to find the best way to find the referring page (ie find out
where the user came from). So far this is the piece of code I have...
Enumeration e = request.getHeaderNames();
String refText = null;
while (e.hasMoreElements())
{
String key = (String)e.nextElement();
if (key.equals("referer"))
{
refText = request.getHeader(key);
break;
}
}
I have to imagine that there's a better way to do this..does anyone have any
insight? I checked google and the servlet javadocs and didn't see anything
that simplified this code. Otherwise, I'll just drop this piece of code
into a util class. Just seeing if I'm reinventing the wheel. Thanks.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>