URL rewriting in xPages

I notice the xPage does URL rewriting ( adding the sessionid to the links )

If I want to add an html tag to my xPage how can I include the sessionid?

Subject: Use the servlet API

The session id is added by a call to HttpServerReesponse.encodeURL(). There is an article in the Domino designer wiki explaining how to get access to the Java request/response objects.