Title servlet 1.1

    It is a Java servlet lets you request titles from HTML pages and return data in JSON format. So your JavaScript application will be able to check out title for any arbitrary URL.

The idea is very simple. Servlets returns JavaScript code. So adding this JavaScript code dynamically to your page lets you bypass any sandbox restrictions and deal with the remote data sources.

How to use it:

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

b) define a servlet in your web.xml file. You can define the following optional initial parameters:

timeout - describes a timeout for your request (in milliseconds).
proxyHost - describes proxy settings for your system.
proxyPort - describes proxy settings for your system.


define a mapping:


Servlet accepts the following parameters:

url - URL to be requested
callback - Optional parameter. Describes a name for your JavaScript callback
encoding - Optional parameter. Describes an encoding for the remote site
name - Optional parameter. Describes a user name (for the protected sites)
password - Optional parameter. Describes a password (for the protected sites)

    The following example illustrates the usage. This code requests info about the following web page http://servletsuite.com. JavaScript function f describes our callback.

<script language="JavaScript">

function f(info)
  var s="Response:" + info.title+"\n"
   +"Size:" + info.length+"\n"


var e = document.createElement("script");
e.src = 'http://your_server/servlet/title?url=http://servletsuite.com&callback=f';


Servlet supports cache so the subsequent requests for the same host will get data from the cache without the getting and parsing the real HTML. If the remote host is not available or title is not provided servlet will return an empty string.

For JSP applications you can use Title taglib.

    For downloading:  titlePackage.jar   

  © Coldbeans     Comments?

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

Also in JSOS: