Geo IP taglib ver. 1.2

    Custom JSP taglib. Lets you calculate geo settings for the given IP address. Taglib uses an external service (ippages.com) as a source for geo information. So it is actually a mashup requested data from the external source. How to use it:
 


<html>
<%@ taglib uri="taglib.tld" prefix="g" %>

<g:GeoIP ip="194.154.66.104" id="A"/>
</html>

Tag creates a page scope variable with the results of geocoding. Name for this variable will be provided in the attribute id. This object has got the following methods:


boolean getStatus() - descibes a status of the request
double getLatitude() - returns a latitude
double getLongitude() - returns a longitude

So in the above mentioned example your JSP page may use some like this:


<% if (A.getStatus()) { %>
Latitude: <%=A.getLatitude()%>
Longitude: <%=A.getLongitude()%>
<% } %>

Tag automatically caches data, so the subsequent requests for the same IP address will use cache.

In your servlets you can use core classes from the taglib for getting geo IP information. E.g.:
 


import com.cj.geoip.*;

GeoIP gp = GeoIP.getInstance();
String ip = "194.154.66.104";

GeoIPBean gb = gp.getInfo(ip);

Tags are:

GeoIP.

Body tag calculates geo coordinates for the given IP address. Attributes are:

1) ip - Optional attribute. Describes an IP address. By default the IP address from the user's request will be used here.
2) id - Optional attribute. Describes a name for the page scope variable (type is com.cj.geoip.GeoIPBean) with the results. Default value is geoip.
3) proxyHost - Optional attribute. Describes a proxy for your host
4) proxyPort - Optional attribute. Describes a proxy for your host

for downloading:

Library: geoiptag.jar     Description: taglib.tld

 © Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in Coldtags: