Posts Tagged Java

Established Programmers Getting Started in Web Development

An acquaintance of mine has recently graduated from college with a degree in computer science.  Where he went, apparently they stressed theory over practice.  He’s got some C++, Lisp, Java, and MySQL experience, but has never touched web development (neither HTML, nor even viewed source on a web page).

He’s hoping to get a job with a company that has him supporting Java applications with web front ends, so to do that he’ll need to get at least tolerable with HTML.  He’s willing to go to training if there’s a course that’ll help, but the obvious concern is that he goes to a 5 day training and spends a significant amount of time covering “Web pages are viewed in web browsers” type material – that is to say, he’s concerned that intro to web development courses are going to be tailored to people looking to set up a family-newsletter or small-business-created-by-the-owner type site.

I’m recommending he start with the W3C tutorials: , which should get him a functional early level of knowledge.  I suggested he could start out trying to make a personal site in HTML w/o leaning on a HTML editor, hopefully this gets him the rudimentary skills he needs.  Other suggestions are welcome!

, , , ,

No Comments

Real Time Command Execution Feedback

Did you ever write a utility ColdFusion script which uses <cfexecute> to run a command and send output back to the browser? It makes for convenient and monitorable remote execution of certain repetitive tasks. My most common use for this sort of thing is for example an rsync process which can be invoked from anywhere in the world, and most recently I’ve been working with Selenium-RC to set up regression test scenarios which can be initiated by business users and business analysts without having to have Selenium IDE installed or know how to use it.

I’ve always found it frustrating though when the task is long-running, and potentially error-prone to not know the success or failure, until the entire command has been executed, and even more frustrating not knowing if it has hung up for some reason today, or does it just have a lot more work to do today than normal?

This little snippet will use Java runtime to capture and pipe the output of the program back to the browser in real time. There’s a couple of caveats surrounding needing to not be used inside a forced-buffer area (like <cfsavecontent>), but otherwise this should work just fine. That means you can’t really use it inside most modern CF frameworks which depend heavily on <cfsavecontent> and the like.

Standard input (stdin) is shut down right at the start of execution; if you wanted to interact with the program in some way (such as to script some responses to prompts), you could undo that and write to it. Standard output (stdout) and standard error (stderr) are sent to the browser and flushed in nearly real time (stderr outputs in red to boot). I use a non-busy sleep via a Java thread to check in on the running program once a second for new output. Return value is a structure containing the elements exitValue, stdOut, and stdErr, so you can do further processing with it after the fact.

Anyway, enough blather, here is the code. This is not hyper-efficient (too many string concatenations and HTMLEditFormats), so I don’t recommend you use it in any high volume situations, especially if there’s a lot of output expected from your command, but it’s been sufficient for my needs.

Example usage:

, ,

1 Comment