Good point, Julian
Category show-n-tell thursday
As Julian mentioned, I didn't share how I ended up approaching web page retrieval in Java. Guess I was too busy ranting. Which violates my cardinal rule of programming: leave the emotion out of it. I was reminded again this morning (for other reasons entirely) of a discussion years ago about passion in the workplace... no, not that kind of passion, silly. I mean the tendency for programmers to get all worked up about what they're working on, with which I have historically struggled. As time passes, it becomes less of a problem - ironically, because I know it's a problem and consciously attempt to overcome it, whereas the areas that don't cause me as much trouble often get overlooked and end up causing more problems because I don't focus as much energy on combatting them.
Anyway, the point is that I stubbornly attempt to remain objective about the task at hand, whatever that may be at the time. Occasionally that is perceived as apathy: if I cared more, I'd be more melodramatic. Come to think of it, I've occasionally lost girlfriends for precisely the same reason. But in reality it's the opposite. The more I care about something, the more energy I expend trying to avoid melodrama, because losing objectivity results in blowing things out of proportion, creating problems that didn't exist to begin with, and distracting from the search for a creative solution to any real problems. So when I find myself ranting, it's because for some reason I lost objectivity. Which almost always means that I've settled for a solution that is less than ideal.
In that light, here's the agent in HTTPUpgrade that searches the upgrade site for available versions to present to the user:
See? It works, but it just ain't elegant. I like Julian's better.
As Julian mentioned, I didn't share how I ended up approaching web page retrieval in Java. Guess I was too busy ranting. Which violates my cardinal rule of programming: leave the emotion out of it. I was reminded again this morning (for other reasons entirely) of a discussion years ago about passion in the workplace... no, not that kind of passion, silly. I mean the tendency for programmers to get all worked up about what they're working on, with which I have historically struggled. As time passes, it becomes less of a problem - ironically, because I know it's a problem and consciously attempt to overcome it, whereas the areas that don't cause me as much trouble often get overlooked and end up causing more problems because I don't focus as much energy on combatting them.
Anyway, the point is that I stubbornly attempt to remain objective about the task at hand, whatever that may be at the time. Occasionally that is perceived as apathy: if I cared more, I'd be more melodramatic. Come to think of it, I've occasionally lost girlfriends for precisely the same reason. But in reality it's the opposite. The more I care about something, the more energy I expend trying to avoid melodrama, because losing objectivity results in blowing things out of proportion, creating problems that didn't exist to begin with, and distracting from the search for a creative solution to any real problems. So when I find myself ranting, it's because for some reason I lost objectivity. Which almost always means that I've settled for a solution that is less than ideal.
In that light, here's the agent in HTTPUpgrade that searches the upgrade site for available versions to present to the user:
import java.net.*;
import java.io.*;
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
PrintWriter pw = null;
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
pw = getAgentOutput();
pw.println("Content-type: text/html");
pw.println("Cache-control: no-cache");
Document docContext = agentContext.getDocumentContext();
String strQuery = docContext.getItemValueString("QUERY_STRING");
String strURL = strQuery.substring(strQuery.indexOf("=") + 1, strQuery.lastIndexOf("&"));
URL urlVersionList = new URL(strURL);
DataInputStream in = new DataInputStream(new BufferedInputStream(urlVersionList.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
pw.println(inputLine);
}
in.close();
} catch(Exception e) {
e.printStackTrace(pw);
}
}
}
See? It works, but it just ain't elegant. I like Julian's better.
Comments
Posted by Tim Tripcony At 09:17:13 PM On 06/12/2006 | - Website - |
And I wasn't really bashing you for not putting the code out there, just a little friendly needling. Set the code free man, set it free. If it comes back to you, it's yours to keep. If it doesn't, it's an Internet worm.
- Julian
Posted by Julian Robichaux At 08:23:09 AM On 06/12/2006 | - Website - |