Sometimes it's necessary to return some data as result of an HTTP request which is not supposed to be rendered as HTML (e.g. your own WebDAV protocol implementation) or you want to generate HTML yourself to have maximal control.
There are various ways to do this. For example you can use 'XAgents' which are XPages with a property rendered=false set. See Stephan Wissel's blog for more details.
You can also write something similar to a servlet within a NSF where you receive an HTTPRequest and need to return an HTTPResponse. See in the Extension Library for a sample.
This project shows how you can write a real servlet in your Eclipse IDE that can then be deployed as OSGi bundle.
You can then call your servlet globally or in the context of a database:
http://nheidloff-1/myurl
http://nheidloff-1/mydb.nsf/myurl
The video also shows how to use the IDE to debug your Java code without having to deploy/redeploy anything.