title: Java - Better way to parse a RESTful resource URL
body: <p>I'm new to developing web services in Java (previously I've done them in PHP and Ruby). I'm writing a resource that is of the following format:</p>
  
  <pre><code>&lt;URL&gt;/myService/&lt;domain&gt;/&lt;app_name&gt;/&lt;system_name&gt;
  </code></pre>
  
  <p>As you can see, I've got a three-level resource identifier, and I'm trying to figure out the best way to parse it. The application I'm adding this new service to doesn't make use of Jersey or any RESTful frameworks like that. Instead, it's just extending HttpServlet.</p>
  
  <p>Currently they're following an algorithm like this:</p>
  
  <ul>
  <li>Call <code>request.getPathInfo()</code></li>
  <li>Replace the "/" characters in the path info with "." characters</li>
  <li>Use <code>String.substring</code> methods to extract individual pieces of information for this resource from the pathInfo string.</li>
  </ul>
  
  <p>This doesn't seem very elegant to me, and I'm looking for a better way. I know that using the javax.ws.rs package makes this very easy (using @Path and @PathParam annotations), but using Jersey is probably not an option.</p>
  
  <p>Using only the base HttpServletRequest object and standard Java libraries, is there a better way to parse this information than the method described above?</p>