Re: The best way to integrate servlets with restlets

2009-06-30 Thread Rhett Sutphin
Hi Tamer,

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  
 rich web
 client as well as a REST API. I chose to use RESTLET for my REST  
 API. Now
 when it comes to the web interface, I have two choices:
 1. either infest my application with countless javascript code  
 (which would
 call the REST API then render)

[Side note: don't reject JavaScript out of hand.  With an appropriate  
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.

 I chose to stay away from javascript as much as possible and rely on
 servlets and jsps to render web UI. However, now I am facing a  
 dilema. In
 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  
 I have
 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  
excels at.

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  
 it here.
 I am not concerned about tight integration between Servlets and  
 Restlets as
 long as I can have my RESTLETs not depend on my servlets (but I do  
 not care
 about the opposite).

The Servlet Convertor is to allow you to serve your Restlet  
application via a Servlet container.

 My Questions:
 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  
 rely on
 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.

 Thank you,

 View this message in context:
 Sent from the Restlet Code mailing list archive at



RE: Possible GAE Client issue.

2009-06-30 Thread Matt
Thanks for your response. Bug report added.


jlouvel wrote:
 Hi guys,
 By default, we leverage the HttpURLConnection class which has been
 reimplemented on top of URLFetcher so this should work.
 Thierry will finish his work on automated Restlet editions next week or so
 and we'll be able to resolve such issue more quickly and precisely.
 For now, I suggest to enter a bug report.
 Best regards,
 Jerome Louvel
 Restlet ~ Founder and Lead developer ~
 Noelios Technologies ~ Co-founder ~
 -Message d'origine-
 De : news [] De la part de Philippe Marschall
 Envoyé : vendredi 26 juin 2009 07:14
 À :
 Objet : Re: Possible GAE Client issue.
 Matt wrote:
 Hi there,
 I'm getting the following error whenever I attempt to use the client
 from within the GAE.
 Client client = new Client(Protocol.HTTP);
 Response response = client.get(;);
 Internal Connector Error (1002) - access denied
 ( resolve)
 NB: I'm not using anything other than the default provided by restlet
 I'm not using apache's HttpClient.
 I've updated the gae jar to be the latest snapshot as of yesterday but
 still getting this problem.
 Any suggestions? Or is it a potential bug? 
 You're not allowed to open sockets on GAE/J.

View this message in context:
Sent from the Restlet Discuss mailing list archive at