IP servlet 1.2


    It is a Java servlet lets you request client's IP address. Servlet simply returns IP address. If you are providing a parameter callback than server returns data in JSONP format - so you will be able to use client's IP in your JavaScript applications.

How to use it:

a) copy ipPackage.jar into your WEB-INF/lib directory.

b) define a servlet in your web.xml file:
 

    <servlet>
     <servlet-name>IPServlet</servlet-name>
     <servlet-class>com.jsos.ip.IPServlet</servlet-class>
    </servlet>

define a mapping:
 

    <servlet-mapping>
     <servlet-name>IPServlet</servlet-name>
     <url-pattern>/servlet/ip</url-pattern>
    </servlet-mapping>

Servlet accepts the following parameters:

callback - Optional parameter. Describes a name for your JavaScript callback

    The following example illustrates the usage. JavaScript function f describes our callback.
 


<script language="JavaScript">

function f(info)
{
  alert("Client's IP: "+info);

}

var e = document.createElement("script");
e.src = 'http://your_server/servlet/ip?callback=f';
e.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(e);

</script>

    For downloading:  ipPackage.jar   
 

  © Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: