Clunky java agent code?

I am new to domino so forgive me if this is a ‘newbie’ style question. I am looking for a way to access a file that has been run through the server and the only way that I have found to do this is similar to the code at the bottom. Is there a better way to get to the output without having to go through the localhost? Or is this just the standard way this type of thing is done and I should just live with it? It just seems kind of clunky to me.

Regards,

-Jason

public void NotesMain() {

try {

Session session = getSession();

AgentContext agentContext = session.getAgentContext();

URL url = new URL(“http://127.0.0.1/http_post_test.nsf/test_form?CreateDocument”);

URLConnection connection = url.openConnection();

connection.setUseCaches(false);

connection.setDoOutput (true);

BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));

String line;

while(null != (line = in.readLine())) {

System.out.println(line);

}

in.close();

} catch(Exception e) {

e.printStackTrace();

}

}

Subject: clunky java agent code?

Ick. What are you trying to do? What does “access a file that has been run through the server” mean?

Cheers!

Luke

Subject: clunky java agent code?

When you write localhost or 127.0.0.1, it is just a way to specify the current machine. The whole point of a URL is that it is uniform – the form of the URL is the same no matter whether the resource is on the current machine or on some other machine. Where’s the clunk? How would you prefer to write it?

Subject: RE: clunky java agent code?

It just seems that their should be a more elegant way to get at the information than having to go through an http call.

Like I said, I am newbie to domino so I don’t know what is really going on behind the scenes here. Intuitively though it seems like you are querying port 80 and capturing the stream from that query. Does this no incur much overhead in Domino or is it such a standardized practice that it has been optimized?

Also, I have read this is a way to get dynamic content from domino. I guess what I am asking is this the only way?

-Jason

Subject: RE: clunky java agent code?

When you write “get at the information” and “querying port 80”, you make it sound like the data is just sitting there waiting to be fetched. That is not the case. You have to make a specific request to Domino to make it get the raw data from the NSF file and transform it into HTML. When it has done all this work for you, it sends the HTML data back to your program. Yes, this is standardized and optimized. For example, it is the same mechanism that your browser uses to display thw web page you are reading now.If you need to get HTML formatted for a browser client out of a Domino server, then yes, HTTP is the only way.

It is not just web servers that work this way. Huge numbers of server programs use the same mechanism. For example, when I want to get data from one of my MySQL databases, I send the query to port 3306 on localhost, and the database server sends the results back.

This is elegant because it allows the server to be moved to another machine without changing any syntax, and it allows the server program and the client programs that use it to be independent.

I do not know what you mean by “dynamic content”. Perhaps, as Luke suggests, if you explain what you are really trying to achieve then someone can suggest another method.