Single Webapp Jetty 7 Configuration

When developing a webapp in Java, I prefer to use Jetty when possible. While it’s easy enough to drop an exploded war into the webapps directory, often I want the app hosted at the root without all of the extra options that Jetty includes by default.

With a simple XML configuration, this is pretty straightforward to do. First, get Jetty (I’m using the latest stable of version 7):

$ wget -r -nc -np -nd -A zip "http://download.eclipse.org/jetty/stable-7/dist/"
$ unzip jetty-*.zip
$ rm jetty-*.zip

Then download this config file to the Jetty directory:

$ cd jetty-*
$ wget "https://raw.github.com/gist/1130234/638e7405f901b378bb8daa18ef1d81fabc9023de/jetty-single-webapp.xml"

By default, Jetty will include a number of additional config files. To ignore them, an empty --ini= parameter is required, like so:

$ java -Dwebapp=/path/to/webapp -jar start.jar --ini= jetty-single-webapp.xml

Note the space directly after --ini=

The config file refers to 3 properties: jetty.port, webapp, and webapp.context.

  • jetty.port: the port to which the HTTP server is bound.
  • webapp: the filesystem path, relative to the Jetty directory, that will be used as the root of the webapp (defaults to “webapp” next to the Jetty directory).
  • webapp.context: the base context path where the webapp will be published (defaults to “/”).

That’s all there is to it. With this it’s easy to host different apps by changing the webapp property or run multiple apps with multiple Jetty instances (on different ports with the jetty.port property), plus Jetty starts up quicker without the extra options.

Quick & Easy random.org on OS X

Previously I shared a quick and easy app for generating a random string into the clipboard, based on /dev/random.

But what if we wanted true random?

By leveraging the random.org api this turns out to be almost as trivial as the previous version:

With the addition of an icon (based on the random.org logo font) we have Random String.app:

Download Random String.app

Be away that random.org has daily quota restrictions, so if you use it a lot be sure to keep an eye on your quota.

Quick & Easy Random Alphanumeric on OS X (w/ AppleScript)

Often I find myself in situations where a little random string would be very handy, be it a password, a unique identifier, or some sort of throwaway data. The String Generator at random.org is great (and supposedly very random, so a must wherever true randomness is required), but I was looking for something quicker.

In a unixy environment, the following works:

$ head /dev/random | md5
96cfcc873597b02dfa97d3fc0a2fd9a0

While this does work in OS X, it would be nice to run it in a way that would work with my preferred app launcher, ideally without context switching away from whatever I was working on (i.e., not having to bring up Terminal).

The following is one line of AppleScript that leverages the same technique as above, but puts the resulting data into the system clipboard:

After generating a .app from the ActionScript, one simply runs the app and pastes the result as desired.

The generic .app icon is quite bland, so a tiny bit of Context Free Art generates an icon:

Which looks like:

Random MD5.app Icon

Put it all together and we have a simple Random MD5.app:

Download Random MD5.app

About