I'm trying to figure out what the best options are for developing a RESTful web application with Java EE 6. For example, I want to be able to interpret a URL like so:
GET www.myapp.com/customers/1 - returns a web page displaying details about a customer with id 1.
The only two options I can think of are
- Using Spring MVC 3
- Using a JAX-RS specification that allows you to render views - I heard RESTEasy integrates with Spring MVC?
Are there any other frameworks that will allow you to develop web applications like this? Also I would greatly appreciate insight as to why one framework may be better than another.
Another consideration of mine is what view technologies can you use with the framework? I've heard that many view technologies integrate with Spring MVC, such as Velocity and Tapestry... are these easily integrated or will I run into numerous problems? One essential is that I need templating (like master pages in ASP.NET).
I'm pretty new to the Java EE world - I'm use to Microsoft where they give you one option. I'm a really big fan of ASP.NET MVC - is there something similar to that in the Java world (or is Spring MVC it?).
I'm not use to all these choices... HELP!
Thanks for any advice/suggestions.
I'd recommend you have a look at:
- RESTLet
- Play
- Grails with the REST plugin for Grails
- Jersey
- RestEasy
(One question though: why specifically do you need to be able to integrate with Java EE?)
EDIT: In the case where you absolutely want to use the Java EE APIs, then as mentioned by BalusC, JAX-RS is your solution of choice. Restlet and Jersey both support it. I don't know about RESTEasy, but the JAX-RS Wikipedia page mentions it does.
It's not JavaEE, just JavaSE (some may say that's a Good Thing) but the Play Framework is RESTful, and in my opinion is also very nice to use.
I've decided to go with Spring MVC. I didn't go for JSF 2 because it's just not very RESTful - it seems like a lot of work to get RESTful URLs (having to use plugins), it holds state server-side, and its not action oriented. Play seems like a very cool framework, but it isn't mature enough for me to justify using it yet (and I'm still not sure if you could use Java EE with it).
Spring MVC 3 allows you to map your URL's RESTfully and is action oriented - which I prefer.
I was looking into Grails which looks very promising but is still relatively new and it doesn't look like it has support for Java EE 6 yet.
I'll second @Haylem's recommendation of Restlet. We have a large project that leverages Java EE somewhat (some stateless session beans, Glassfish, a timer bean, servlets, JDBC, JNDI). Restlet fits in very well: you can run a set of web services inside a single Restlet-based servlet. You get an enormous amount of functionality for relatively little effort. We've been quite happy with it.
Since you have a Rails background, I'd recommend that you take a look at Scooter framework which ports lots of good stuff from Rails to Java. Like Struts and SpringMVC, it is an action based MVC framework. It handles restful routes beautifully. See the restful urls: http://scooterframework.com/docs/restful_routing.html
Its view layer technology is simply JSP, managed by SiteMesh layout framework. But it processes StringTemplate view files too.