Getting Path (context root) to the Application in Restlet

Posted by Chad Gorshing on Stack Overflow See other posts from Stack Overflow or by Chad Gorshing
Published on 2010-04-29T15:48:45Z Indexed on 2010/04/30 3:37 UTC
Read the original article Hit count: 290

Filed under:

I am needing to get the application root within a Restlet resource class (it extends ServerResource). My end goal is trying to return a full explicit path to another Resource.

I am currently using getRequest().getResourceRef().getPath() and this almost gets me what I need. This does not return the full URL (like http://example.com/app), it returns to me /resourceName. So two problems I'm having with that, one is it is missing the schema (the http or https part) and server name, the other is it does not return where the application has been mounted to.

So given a person resource at 'http://dev.example.com/app_name/person', I would like to find a way to get back 'http://dev.example.com/app_name'.

I am using Restlet 2.0 RC3 and deploying it to GAE.

© Stack Overflow or respective owner

Related posts about restlet