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.
for downloading: Library: geoiptag.jar Description: taglib.tld See also Coldtags suite - the largest collection of custom JSP tags.
|
Also in Coldtags:
|