ID servlet v. 1.1


Yes, this servlet simply returns unique ID. In JSON (or JSONP) format. You can use it in your Javascript application for getting unique ID from the server. How to use it:

1) download idPackage.jar and save it in WEB-INF/lib

2) describe ID servlet in web.xml file  


    <servlet>
     <servlet-name>IDServlet</servlet-name>
     <servlet-class>com.jsos.id.IDServlet</servlet-class>
    </servlet>

3) define a mapping:
 


    <servlet-mapping>
     <servlet-name>IDServlet</servlet-name>
     <url-pattern>/servlet/ID</url-pattern>
    </servlet-mapping>

and now you can use it. For JSON request call http://your_host/servlet/ID, for JSONP use a parameter callback that describes your Javascript function. In this example our callback function is myID:
 



function myID(v)
{
  alert("New ID:"+v.id);
}

var cbscript = document.createElement("script");
cbscript.src = 'http://your_host/servlet/ID?callback=myID';
cbscript.type = 'text/javascript';
document.body.appendChild(cbscript);

For downloading:

servlet: idPackage.jar  
 

 © Coldbeans    Comments?
 

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

Also in Coldtags: