Hello, actually, the second parameter in the Redirector constructor is a template using a set of known variables (see [0]). You should be able to use the shipped Redirector, as follow (or something similar) new Redirector(getContext(), "http://192.168.100.1:8080/RESTfulServices{rr}", Redirector.MODE_CLIENT_DISPATCHER));
Don't forget to declare the client HTTP connector on the component (such redirection is seen as a new client call issued by the Component). This is done in the web.xml file see ([1]) <servlet> [...] <init-param> <param-name>org.restlet.clients</param-name> <param-value>HTTP</param-value> </init-param> [...] </servlet> [0] http://www.restlet.org/documentation/2.0/jse/api/org/restlet/util/Resolver.html [1] http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html Best regards, Thierry Boileau > Hello everybody, > > Could please anyone help me to write a universal redirector to match > all requests and to redirected them to a remote host? > Example: > Start: /redirect/RESTfulServices/resources/customers/pkey/2176172632 > Finish: > http://192.168.100.1:8080/RESTfulServices/resources/customers/pkey/2176172632 > > > GWT Client side: > ClientResource r = new > ClientResource("/redirect/RESTfulServices/resources/customers/pkey/2176172632"); > > > Server side class TestRestletApplication extends Application (my > web.xml was changed to forward all /redirect/* requests to > TestRestletApplication) > Router router = new Router(getContext()); > router.attach("/RESTfulServices", new MyRedirector(getContext(), null)); > //<-- this is wrong > > and MyRedirector class: > public class MyRedirector extends Redirector { > > public MyRedirector(Context context, String targetTemplate) { > // By default, the mode is MODE_CLIENT_DISPATCHER > super(context, targetTemplate); > } > > @Override > protected Reference getTargetRef(Request request, Response response) { > Reference ref = request.getResourceRef(); > ref.setHostDomain("192.168.100.1"); > ref.setHostPort(8080); > //<-- here is missing something > return ref; > } > } > Thank you for helping me. > > ab > ------------------------------------------------------------------------ > View this message in context: How to write an Universal redirector > <http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4620578.html> > Sent from the Restlet Discuss mailing list archive > <http://n2.nabble.com/Restlet-Discuss-f1400322.html> at Nabble.com. ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2451393