There is an old saying called the [nail rhyme](http://www.enchantedlearning.com/Nailrhyme.html) that starts off “For Want of a nail…” and ends “… the kingdom was lost”.
I attended a conference on the weekend. There was a session denigrating Struts and promoting Webwork. I didn’t go to the session because I have used and intensely dislike both web frameworks. The reasons why can be the topic for another blog. This was much to the disappointment of the speakers who aimed a jibe at me before realising I was absent.
Later that evening over several beers the most zealous of the presenters found me and sought to convert me to the new truth.
I said that “we used JSP, JSTL and our own home-grown set of classes for our framework and that it seemed to work very well. We roundtrip with a designer. The pages are very fast to edit and test. No problems.”
“But” he said, “you have to build a jar and deploy to your server after each edit before you view or test”. That was when the penny dropped. It occurred to me much of the effort to find alternatives to JSP was to avoid this problem.
There are two ways of avoiding the build-jar-deploy-unpack problem:
* use an exploded directory structure
* use a small shell script called weblinks.sh
Exploded Directory Structure
—————————-
In this approach you configure the app server to use a directory rather than ears, wars and jars. We use Orion application server, and I have used that approach in the past.
Both the IDE and the app server are pointing to the same place. You press save. Then if you run a test against the page or call the page, the app server notes the new timestamp, parses, compiles and executes it. Easy.
Weblinks.sh
———–
But we are even lazier. What if you could leave your build script to create jars, wars and ears and still get instant deployment.
Here’s how:
1. deploy the app as an ear.
2. let the app server expand it
3. delete each web resource (jsp, image, javascript file etc) and replace it with a symbolic link to your IDE’s web source directory.
4. Edit your JSPs, press save amd voila! Instant deployment.
The technique works equally well for a Java IDE, Dreamweaver or any other HTML or text editor.
As with the previous technique, when a file is saved the app server sees a new timestamp. Instant deployment.
Attached is a Unix/Linux/MacOSX shell script called [weblinks.sh](http://gregluck.com/blog/weblinks.sh) which does this.
Now back to my missionary friend. He objected to the shell script on the basis that it was “changing the operating system”. The last time I checked, if you have a shell account you can write scripts.
“But I run Windows”, he said. Another penny dropped. Just in case any of my readers was in any doubt I have developing on Linux for the last six years, which I mix up with a bit of development on my Mac. Shell scripts are easy on both. On Windows, I guess if the IDE does not do it it is not possible.
Well, the last time I checked, it was possible to write batch scripts in the miserable DOS. If you are running on NTFS on W2K or higher, then you can create symbolic links. See [here](http://shell-shocked.org/article.php?id=284) for a discussion of the command line tools and options for doing so.
For want of a symbolic link
—————————
For want of a symbolic link
the JSP was lost.
For want of a JSP
designer roundtripping was lost.
For want of a designer
usability was lost.
For want of usability
the project was cancelled.
For want of a project
the developer was sacked.
Comments