title: The simplest way to map URLs to request handlers in Java
body: <p>I'm prototyping a simple RPC server in Java for an internal application.  </p>
  
  <p>While eventually I'd like to switch to a specialized, high performance RPC library such as MessagePack, Apache Avro, or the Java bindings to 0mq, right now I'd like to keep things as simple as possible, so am starting with JSON over HTTP.  I'd like to use Jetty so that I can embed the webserver and make installation and deployment as easy as possible.  But I don't have much experience with Java webdev, and am getting hung up on the very simple challenge of associating each of a handful of specific request handler objects with a specific URL.  My general impression is that this may be the kind of thing the web.xml file is used for, but I'd rather wire it into the source code if possible.  </p>
  
  <p>I should emphasize that I need no interesting webapp functionality like sessions, templating, database access, etc.  I just need to get a JSON string out of a POST request body, do stuff, and then write a string back in the response. </p>
  
  <p>So basically, what's the best way to, say, write two request handlers (servlets?), which return the request body uppercased and lowercased, respectively, and register them with the paths "/upper" and "/lower" on my server, preferably without using a config file.  This will be taking place in an embedded Jetty app, but you certainly don't need to depend on that if you don't want to.</p>