JavaAgent/Backing Bean

URL connect, XML on C:/


System Requirements:

Download Domino Designer 8.5.2 Environment (DDE)


Build a connection to a Lotus Notes Domino Database, create an XML document using a JavaAgent, perform a sort of handshake with the XML data, pulled into a bean class via URL. Build a new XML file with URL data, submit file to your C drive.


Information contained in the following is presented as is. This tutorial assumes you have basic programming knowledge. All tutorials are based on an Eclipse/Eclipse-based software. Should you need to familiarize yourself with a certain Eclipse environment, prior to continuing this tutorial, please stop now and see our Tutorials page...

Build XML file to URL

At this point we assume Domino Designer 8.5.2 is downloaded/installed and a new JavaAgent, is already created. You are building XML tags with data from a view in your database. You will pull these tags through URL and save as a file to local C drive, or drive of choice. Copy and paste below code to your environment for each code samples.

TIP: Add an alias name via the JavaAgent's properties, serves the purpose of the name of the XML file: dashboardchartdata.xml



* Created: 2011.

* Program: DashboardChartJavaAgent (

* XML data for Xpages/Charts


//load imports

import lotus.domino.*;



* @author Dököll Solutions, Inc.

* @version 2011.



//begin class

public class JavaAgent extends AgentBase {

//open method, this actually runs the whole App

public void NotesMain() {

//let's add a try catch here, grab errors near the end

try {

//open our session...

Session session = getSession();

//load info console for debugging purposes

System.out.println("We've got a session..." + session);

//load agentContext, grab database in question

AgentContext agentContext = session.getAgentContext();

Database currdb = agentContext.getCurrentDatabase();

//load info console for debugging purposes

System.out.println("connected to database..." + currdb);

//load view in question

View view = currdb.getView("SiteList");

//load info console for debugging purposes

System.out.println("We've got our view!" + view);

//load first document

Document doc;

Document tempDoc;

doc = view.getFirstDocument();


PrintWriter pw = getAgentOutput();




//Write out the Opening Tags

pw.println("<?xml version='1.0' encoding='UTF-8' ?>");


//loop though docs and fill xml tags

while (doc != null) {










tempDoc = view.getNextDocument(doc);

//recycle, free up memory...



doc = audoc;


//close the root tag


} catch(Exception e) {





Bean it!

Create a bean, you are now ready to pull in XML data from URL, save it to your C drive; data that can be loaded to Xpages, perhaps styled with an XSL sheet, and load to browser. You can use XMLURL2FileCreate.GetXMLFromURL() in your Xpage button to run the code (or use SSJS onBeforePageLoad). Copy and paste below to your environment, areas of interest have been highlighted for your convenience.


* Created: 2012.

* Program:

* XML data for Xpages/Charts



//load imports



import javax.faces.context.FacesContext;

import lotus.domino.local.Database;


* @author Dököll Solutions, Inc.

* @version 2012.



public class XMLURL2FileCreate {

public void GetXMLFromURL() {

try {

//TO DO: Send ip and other info to back-end if page firing

//via button code by multiple users...

//Get XML file from URL.

URL xmlURL = new URL("http", "localhost", 80,


// Set up Connection to URL, grab file

URLConnection connectXML = xmlURL.openConnection();

// connect to URL.... grab file


// Build URL file into new XML file

// ...

PrintWriter prWriter = new PrintWriter(new FileWriter(


// Read URL data into new XML file

BufferedReader bufferRead = new BufferedReader(

new InputStreamReader(connectXML.getInputStream()));

// ...

String dataRead = bufferRead.readLine();

// ...

while (dataRead != null) {


dataRead = bufferRead.readLine();


//close writer...


} catch (Exception e) {

System.out.println("Error: " + e);





You can now put data where you need it in XML file format to be used by other software/systems.

TIP: Use the XML file on C:/ as part of Xpages via iFrames, load to reusable custom controls, styled with XSL stylesheets, or build and embed charts using the XML file as DataSource.

Questions, comments, please post a brief message on our Contact form on the main site.

Thank you for coming...