I recently started looking for “ Sinatra- clone, an ultra-lightweight web infrastructure for Java. Something that allows you to define all your URL routing in one clean block of code and maybe even write implementations right there for simple cases. Unlike Servlets ... where you either use XML or scatter annotations throughout the code base, and you need completely separate Servlet classes for even the simplest route handlers.
Most parameters are either excessively excessive and / or counter this approach (e.g. Spring, JEE), or you can use Scala or Groovy instead of pure Java (e.g. Scalatra, Play, Ratpack). Spark and Vert.x are interesting, and I fiddled with both in my personal projects, but I would like to see a little more maturity and durability before pushing them to production projects at my work.
Then it occurred to me that the JAX-RS basically covers everything I am talking about. So far, I have only used Jersey in the context of RESTful "services" ... returned JSON for AJAX or XML calls to other server systems. However, there is no reason the JAX-RS method cannot also return HTML (or something else) to the browser and replace the need for a full Servlet class. JAX-RS gives you access to session state if you want it, and tools like filters / interceptors that you need for non-trivial applications. If you add some kind of template library (for example, Velocity, FreeMarker), then you pretty much have the essence of Sinatra in the widely supported Java standard. JAX-RS 2.0 even gives you asynchronous HTTP (i.e. long polling, push server), which seems simpler than version Servlet 3.x.
So, I'm curious why at the moment you can still use traditional servlets in general? Obviously, people have their own subjective preferences ... some people may simply prefer to have a separate class for each route handler or want the lowest learning curve to be possible when placing new developers, etc. However, it is MANDATORY to say what functionality (if any) is offered from Servlet 3.x, which is simply not available in JAX-RS (or may be more painful to use)? When choosing between traditional servlets or JAX-RS for a web application, are there still cases where servlets are undoubtedly the more appropriate design choice?