I think this is more of a discuss topic, so I'm moving it there.
On Jun 30, 2009, at 9:13 AM, tameremil wrote:
I am currently working on an application where I have to provide a
client as well as a REST API. I chose to use RESTLET for my REST
when it comes to the web interface, I have two choices:
call the REST API then render)
toolkit to patch over the inter-browser messiness (I like jQuery and
YUI) and good unit tests, a dynamic, JS-based UI could be your best
2. use servlets and jsps.
servlets and jsps to render web UI. However, now I am facing a
order to call the REST API from my servlets I am using the RESTLET
this approach has proved to be inefficient. Every time I make a call
to parse the returned JSON and go through pain to extract API call
It sounds like you have (conceptually) a single server which provides
both an HTML-based web GUI and a JSON API. If that's so, that's a
common case. You can use Restlet for both representations -- in fact,
this sort of thing is one of the things the RESTful architecture style
The idea is that you implement the same Resources, with the same
associated logic, but allow them to return different Representations
based on what the client requests. This concept is Content
Negotiation and Restlet supports it. I'd suggest reading the
O'Reilly RESTful Web Services book for more info.
One caveat is that I don't think you can use JSP to render a Restlet
Representation. You can use FreeMarker, though, which is similar
(some would say better).
I read about the Servlet Convertor, but I am not sure how I can use
I am not concerned about tight integration between Servlets and
long as I can have my RESTLETs not depend on my servlets (but I do
about the opposite).
The Servlet Convertor is to allow you to serve your Restlet
application via a Servlet container.
1. What is the best way to integrate my servlet with the RESTLETs?
2. Is there a way for me to pass java objects from the restlet to the
servlet? This way in the servlet I can extract java objects and not
re-assembling the JSON or XML contained in the Response
For a new application (and assuming I understand what you're trying to
do), I'd suggest using content negotation in Restlet and not using
Servlet/JSP at all.
If you really don't want to do that, or if you already have a large
investment in JSP-based views, I'd extract the business logic into a
separate layer and make it available to both your servlets and your
Please let me know if my question is not clear.
I am in a tough bind and would appreciate any and all help.
View this message in context:
Sent from the Restlet Code mailing list archive at Nabble.com.