XPages don't have a notion of agents (you can call them in the backend, but you won't get anything back from the print statements), so it seems a step back. On closer inspection however one can see, that XPages offer a greater flexibility for the same pattern of use. Every element on an XPages has a "render" attribute which determines if the element should be rendered. "Every" includes the page itself. So when you set the page's render property to false, well the XPage engine renders nothing. So you get an empty canvas you can paint on. XPages still provides you with the page event and access to scoped variables, so you can code better performing "agents" since you can keep lookups in memory. To get the equivalent to the LotusScript print you need the ResponseWriter from the externalContext. To set the content type you use the response.setContentType also to be found in the external Context. A sample snippet you could put in the afterRenderResponse event of your page would look like this (error handling omitted):
// The external context gives access to the servlet environment var exCon = facesContext.getExternalContext(); // The writer is the closest you get to a PRINT statement // If you need to output binary data, use the stream instead var writer = facesContext.getResponseWriter(); // The servlet's response, check the J2EE documentation what you can do var response = exCon.getResponse(); // In this example we want to deliver xml and make sure it doesn't get cached response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); // Here all your output will be written writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<christmas date\"24Dec\" />"); // We tell the writer we are through writer.endDocument(); facesContext.responseComplete(); writer.close();// Update:On 8.5.2 or later
writer.close()seems not be necessary/be rather harmful. Read the revisited entry
More information about the FacesContext can be found in the Domino Developer Wiki.
Bonus Tip: Since you do not render anything from the XPage you just used, why not take that empty page and write the documentation for that XAgent?
Update: Other posts on rendering your own output in XPages: