Hello renfeng,

did you try to call the following methods on the request object?
 - request.getResourceRef().getBaseRef()
 - request.getHostRef()
 - request.getRootRef()

Otherwise, you can get the servletContext by casting the context:
        ServletContextAdapter c = (ServletContextAdapter) context;
        c.getServletContext();
But this method creates a strong coupling between your Restlet 
application and the Servlet container environment, and thus is not 
encouraged.

best regards,
Thierry Boileau


> I couldn't find a method to get the base url of ServerServlet. So it
> is hardcoded. Any clue how to retrieve it from the runtime
> environment? Thanks.
>
>  String baseUrl = "/context-root/restlet-root";
>  router.attach("res1", new Redirector(
>    getContext(), baseUrl + "res2",
>    Redirector.MODE_CLIENT_SEE_OTHER));
>
>
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=989754

Reply via email to