RE: Re: Re: Redirect Restlet console statements to an external log file using log4j.properties
Absolutely brilliant! Seems to work perfectly. Thank you so very much. I'll throw this up on the wiki so the next person doesn't have to ask the same question again. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409574
How to register scheme in restlet engine?
I am using Restlet Version 2.0 Milestone 5 (testing). When i try to create ChallengeResponse and set in ClientResource i get the below warning: org.restlet.engine.security.AuthenticatorUtils format WARNING: Challenge scheme SID6 not supported by the Restlet engine. Below is the code: Context context = new Context(); context.getParameters().add(ADAPTER_PARAM, ADAPTER_VALUE); ClientResource clientResource = new ClientResource(context, clientUrl); ClientInfo clientInfo = new ClientInfo(); clientInfo.getAcceptedMediaTypes() .add(new PreferenceMediaType(MEDIA_UDS)); clientResource.setClientInfo(clientInfo); Form requestHeaders = new Form(); requestHeaders.add(HEADER_CORRELATION_ID, _responseId); requestHeaders.add(HEADER_DATE, DateUtils.format(new Date())); clientResource.getRequestAttributes().put(ATTRIBUTE_HEADERS, requestHeaders); ChallengeResponse challengeResponse = new ChallengeResponse(ChallengeScheme, 5J17HSDFSFWRWER:WERSDSDSFSDF//dssdfsz); clientResource.setChallengeResponse(challengeResponse); ChallengeAuthenticator authenticator = new ChallengeAuthenticator(context, ChallengeScheme, realm); Now if i comment the ChallengeResponse code and add the scheme in Form directly it works fine. But doing this is a hack. I want to know how i can register my own scheme. below is the code for setting in Form . // This is a hack and should be done with ChallengeResponse /* Form.add(Authorization, SID6 5J17HSDFSFWRWER:WERSDSDSFSDF//dssdfsz); */ Appreciate prompt response. Thanks, Cobse -- View this message in context: http://n2.nabble.com/How-to-register-scheme-in-restlet-engine-tp3861417p3861417.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409555
RE: Re: Re: Problems when registering a simple Restlet resource under OSGi
Thanks for checking it out Rob. Unfortunately did not work for me, and I again get the following: Oct 20, 2009 6:18:55 PM org.restlet.service.ConverterService toRepresentation WARNING: Unable to find a converter for this object : org.restlet.representation.stringrepresentat...@a44085 Oct 20, 2009 6:18:55 PM org.restlet.engine.log.LogFilter afterHandle INFO: 2009-10-2018:18:55127.0.0.1 - - 8182 GET /helloWorld/hello - 200 0 - 34 http://localhost:8182 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 - Oct 20, 2009 6:18:55 PM org.restlet.engine.http.HttpServerAdapter commit WARNING: A response with a 200 (Ok) status should have an entity. Make sure that resource http://localhost:8182/helloWorld/hello; returns one or sets the status to 204 (No content). And on top of it even: Oct 20, 2009 6:18:55 PM org.restlet.engine.http.StreamServerCall complete WARNING: Unable to shutdown server socket java.net.SocketException: Socket is not connected at sun.nio.ch.SocketChannelImpl.shutdown(Native Method) at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:583) at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:360) at org.restlet.engine.http.StreamServerCall.complete(StreamServerCall.java:108) at org.restlet.engine.http.HttpServerAdapter.commit(HttpServerAdapter.java:441) at org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:150) at org.restlet.engine.http.StreamServerHelper$ConnectionHandler.run(StreamServerHelper.java:89) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269) at java.util.concurrent.FutureTask.run(FutureTask.java:123) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676) at java.lang.Thread.run(Thread.java:613) Some info: - I use Maven with Pax Runner (here I use Felix). - My Restlet version is: 2.0-M3. I think M4 is not available in the public repository. I will check out now some of the snapshots. Any suggestions what else can be tried to find a solution to the problem? Regards, Vlatko -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409449
RE: CLAP - restlet-jee-2.0snapshot
Hi, is anyone there to help? Thanks! Dear All, I am using the restlet-jee-2.0snapshot, jdk5.0 on Tomcat 5.5. I have an application.properties file: WEB-INF/classes/application.properties But I keep getting the following error: java.lang.IllegalArgumentException: Cannot access to the configuration file: clap://system/WEB-INF/classes/application.properties It seems that I am not working properly with the classloader, CLAP. I have tried most ways, clap://thread/.., clap://class...but no luck so far. Here below is the code: Thanks, Sinoea [code] public class DirectoryServletApplication extends Application { /** Freemarker configuration object. */ private Configuration fmc; public static void main(String[] args) throws Exception { // Create a component Component component = new Component(); component.getServers().add(Protocol.HTTP, 8182); component.getClients().add(Protocol.FILE); component.getClients().add(Protocol.CLAP); component.getClients().add(Protocol.HTTP); DirectoryServletApplication application = new DirectoryServletApplication(component.getContext()); // Attach the application to the component and start it component.getDefaultHost().attach(, application); component.start(); } public DirectoryServletApplication(Context context) throws IOException { super(context); getConnectorService().getClientProtocols().add(Protocol.FILE); getConnectorService().getClientProtocols().add(Protocol.CLAP); getConnectorService().getClientProtocols().add(Protocol.HTTP); // Look for the configuration file in the classpath (Here is the PROBLEM) Properties properties = getProperties(clap://system/WEB-INF/classes/application.properties); System.out.println(properties.get(web.root.path)); try { this.fmc = new Configuration(); final File templateDir = new File(C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\directory\\ROOT\\WEB-INF\\template); this.fmc.setDirectoryForTemplateLoading(templateDir); } catch (Exception e) { getLogger().severe(Unable to configure FreeMarker.); e.printStackTrace(); } } @Override public synchronized Restlet createInboundRoot() { // Create a router Restlet that routes each call to a // new instance of HelloWorldResource. Router router = new Router(getContext()); // Defines only one route router.attachDefault(HomePage.class); router.attach(/contactus, ContactUs.class); return router; } /** * Returns the freemarker configuration object. * * @return the freemarker configuration object. */ public Configuration getFmc() { return this.fmc; } /** * Returns a Properties instance loaded from the given URI. * * @param propertiesUri *The URI of the properties file. * @return A Properties instance loaded from the given URI. * @throws IOException */ public static Properties getProperties(String propertiesUri) throws IOException { Reference reference = new Reference(propertiesUri); Response response = new Client(reference.getSchemeProtocol()).get(reference); if (!(response.getStatus().isSuccess() response.isEntityAvailable())) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(Cannot access to the configuration file: \); stringBuilder.append(propertiesUri); stringBuilder.append(\); throw new IllegalArgumentException(stringBuilder.toString()); } Properties properties = new Properties(); properties.load(response.getEntity().getStream()); return properties; } } [/code] [code] ?xml version=1.0 encoding=UTF-8? web-app id=directory version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; display-namedirectory/display-name !-- Application class name -- context-param param-nameorg.restlet.application/param-name param-valueexample.DirectoryServletApplication/param-value /context-param context-param param-nameorg.restlet.clients/param-name param-valueHTTP HTTPS CLAP FILE/param-value /context-param !-- Restlet adapter -- servlet servlet-nameRestletServlet/servlet-name servlet-classorg.restlet.ext.servlet.ServerServlet/servlet-class /servlet
RE: Retrieving Login in a resource
Hello Jerome, First, thanks for your response, it resolve my issue. I use MD5 on the password because it is encrypt in MD5 in my database ( I know it's not very safe, but it's the directive of my manager). Kind regards Laurent Garrigues -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409413
Re: HTTP_BASIC authentication doesn't work in GAE
Hi Jerome, thanks for the snippet. My error was returning the guarded router instead of the authenticator. That way worked in M4 outside GAE/J. Anyway I just verified that everything works fine. Do you know when M5 will be released?? Thanks again. Jerome Louvel wrote: Hi Patrizio, Thierry just did a test with the latest snapshot and HTTP BASIC authentication does work. Here is attached a quick code snippet that he wrote based on your code sample. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com De : Patrizio Munzi [mailto:patrizio.mu...@eris4.com] Envoyé : mardi 20 octobre 2009 09:27 À : discuss@restlet.tigris.org Objet : Re: HTTP_BASIC authentication doesn't work in GAE Hi Jerome, did you miss my last mail..?? I'm having trouble attaching the authenticator with the new snapshot. Regards Patrizio Munzi wrote: Hi Jerome, I'm trying to test latest snapshot but I'm not able anymore to attach an authenticator to my router. Using the same snippet as before: --- public Restlet createRoot() { // Create a router Restlet that defines routes. Router router = new Router(getContext()); // Defines a route for the resource "list of items" router.attach("/addcall", CallResource.class); router.attach("/addsms", SMSResource.class); ChallengeAuthenticator authenticator = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "com.eris4.warp4.callfriends.server.restlet"); MapVerifier verifier = new MapVerifier(); verifier.getLocalSecrets().put("callFriends", "callFriends".toCharArray()); authenticator.setVerifier(verifier); authenticator.setNext(router); Router guardedRouter = new Router(getContext()); guardedRouter.attach("/", authenticator); return guardedRouter; } - I get a Resource not found from the client. Has something changed on guarding mechanism..?? Please let me know so that I can go further. BR Jerome Louvel wrote: Hi Patrizio, We recently moved all JAAS dependencies from Restlet Core to a JAAS extension. This should solve your issue. Could you test with a recent 2.0 snapshot and let us know? Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com Patrizio Munzi a écrit : Ok, thank you. Thierry Boileau wrote: Hello Patrizio, I've entered a new issue for this problem : http://restlet.tigris.org/issues/show_bug.cgi?id=893. Thanks for your report. Best regards, Thierry Boileau Hi everybody, I think I've found a problem of Restlet Authentication mechanism with GAE. I have got this simple guard: -- public Restlet createRoot() { // Create a router Restlet that defines routes. Router router = new Router(getContext()); // Defines a route for the resource "list of items" router.attach("/addcall", CallResource.class); router.attach("/addsms", SMSResource.class); ChallengeAuthenticator authenticator = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "com.eris4.warp4.callfriends.server.restlet"); MapVerifier verifier = new MapVerifier(); verifier.getSecrets().put("callFriends", "callFriends".toCharArray()); authenticator.setVerifier(verifier); authenticator.setNext(router); Router guardedRouter = new Router(getContext()); guardedRouter.attach("/", authenticator); return guardedRouter; } -- and this simple client: -- public static void main(String[] args) throws ResourceException { // Client client = new Client(new Context(), Protocol.HTTP); // client.getContext().getParameters().add("converter", "com.noelios.restlet.http.HttpClientConverter"); Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null)); Client client = new Client(Protocol.HTTP); Status resultStatus = null; try { Form form = new Form();
RE: HTTP_BASIC authentication doesn't work in GAE
Hi Patrizio, Thanks for the confirmation ! Restlet 2.0 M6 is expected next month. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org/ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com/ http://www.noelios.com De : Patrizio Munzi [mailto:patrizio.mu...@eris4.com] Envoyé : mercredi 21 octobre 2009 10:30 À : discuss@restlet.tigris.org Objet : Re: HTTP_BASIC authentication doesn't work in GAE Hi Jerome, thanks for the snippet. My error was returning the guarded router instead of the authenticator. That way worked in M4 outside GAE/J. Anyway I just verified that everything works fine. Do you know when M5 will be released?? Thanks again. Jerome Louvel wrote: Hi Patrizio, Thierry just did a test with the latest snapshot and HTTP BASIC authentication does work. Here is attached a quick code snippet that he wrote based on your code sample. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org/ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com/ http://www.noelios.com De : Patrizio Munzi [mailto:patrizio.mu...@eris4.com] Envoyé : mardi 20 octobre 2009 09:27 À : discuss@restlet.tigris.org Objet : Re: HTTP_BASIC authentication doesn't work in GAE Hi Jerome, did you miss my last mail..?? I'm having trouble attaching the authenticator with the new snapshot. Regards Patrizio Munzi wrote: Hi Jerome, I'm trying to test latest snapshot but I'm not able anymore to attach an authenticator to my router. Using the same snippet as before: --- public Restlet createRoot() { // Create a router Restlet that defines routes. Router router = new Router(getContext()); // Defines a route for the resource list of items router.attach(/addcall, CallResource.class); router.attach(/addsms, SMSResource.class); ChallengeAuthenticator authenticator = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, com.eris4.warp4.callfriends.server.restlet); MapVerifier verifier = new MapVerifier(); verifier.getLocalSecrets().put(callFriends, callFriends.toCharArray()); authenticator.setVerifier(verifier); authenticator.setNext(router); Router guardedRouter = new Router(getContext()); guardedRouter.attach(/, authenticator); return guardedRouter; } - I get a Resource not found from the client. Has something changed on guarding mechanism..?? Please let me know so that I can go further. BR Jerome Louvel wrote: Hi Patrizio, We recently moved all JAAS dependencies from Restlet Core to a JAAS extension. This should solve your issue. Could you test with a recent 2.0 snapshot and let us know? Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com Patrizio Munzi a écrit : Ok, thank you. Thierry Boileau wrote: Hello Patrizio, I've entered a new issue for this problem : http://restlet.tigris.org/issues/show_bug.cgi?id=893. Thanks for your report. Best regards, Thierry Boileau Hi everybody, I think I've found a problem of Restlet Authentication mechanism with GAE. I have got this simple guard: -- public Restlet createRoot() { // Create a router Restlet that defines routes. Router router = new Router(getContext()); // Defines a route for the resource list of items router.attach(/addcall, CallResource.class); router.attach(/addsms, SMSResource.class); ChallengeAuthenticator authenticator = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, com.eris4.warp4.callfriends.server.restlet); MapVerifier verifier = new MapVerifier(); verifier.getSecrets().put(callFriends, callFriends.toCharArray()); authenticator.setVerifier(verifier); authenticator.setNext(router); Router guardedRouter = new Router(getContext()); guardedRouter.attach(/, authenticator); return guardedRouter; } -- and this simple client: -- public static void main(String[] args) throws ResourceException { //Client client = new Client(new Context(), Protocol.HTTP); //client.getContext().getParameters().add(converter, com.noelios.restlet.http.HttpClientConverter); Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null)); Client client = new Client(Protocol.HTTP); Status resultStatus = null; try { Form form = new Form(); form.add(param1, 1); Representation callRepresentation = form.getWebRepresentation(); Request request = new Request(Method.POST, url); ChallengeResponse authentication = new
Re: Get secrets in resources
Hello, gonzajg a écrit : Is there a way to get the challengeresponse in resources? You should be able to get them in a ServerResource using ServerResource#getChallengeResponse() Then you could do a *getIdentifier()* and *getSecret()* Laurent. -- Laurent Rustuel, Alten contractor for Genesys, an Alcatel-Lucent Company -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409716
Trouble with ServerServlet
Hi, I'm having some trouble with ServerServlet, and am a bit stuck. What I've done is to subclass ServerServlet and override the createApplication() method to create and return my own subclass of Application. Then, in start() I create and initialize my whole internal application setup. When the Tomcat container starts upp I can see that start() is being called properly. So far so good. But, when I redeploy the application stop() is not always called on the Application (only sometimes!), and so my app is not properly shutdown, which then causes problems when the next version is started. I can see that ServerServlet.destroy() *is* called when webapp is redeployed, but it doesn't call stop() on my application. When looking in the ServerServlet code it's a bit weird, because the init() code calls getApplication().start(), but destroy() calls getComponent().stop()! I'm guessing my problem is somewhere with that. Why aren't these methods starting/stopping the same thing? Is there something else I'm missing? Is it a bug in my code or Restlet? Should I implement my own Component instead of Application? thanks, Rickard -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409718
Re: Get secrets in resources
thanks Laurent! it worked! Laurent Rustuel wrote: Hello, gonzajg a écrit : Is there a way to get the challengeresponse in resources? You should be able to get them in a ServerResource using ServerResource#getChallengeResponse() Then you could do a *getIdentifier()* and *getSecret()* Laurent. -- Laurent Rustuel, Alten contractor for Genesys, an Alcatel-Lucent Company -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409716 -- View this message in context: http://n2.nabble.com/Get-secrets-in-resources-tp3858413p3864957.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409755
Re: Re: Re: Problems when registering a simple Restlet resource under OSGi
If the problem recurs with 2.0M5 or a recent trunk snapshot, let me know and I'll download Pax Runner / Felix to look again. I've seen the socket is not connected thing when I use the internal HTTP connector and certain browsers; it's not actually harmful, just annoying. The internal HTTP connector is really only for test/demo/super-light purposes -- best to choose any of the excellent server connectors available. I have been using Jetty happily for years, but have been impressed by a first look at the new Netty connector that was just contributed. But let's get to the root of your environment problem first, as choosing extensions can also be fun, different, and exciting under OSGi. On Tue, Oct 20, 2009 at 12:29 PM, Vlatko Davidovski vdavidov...@gmail.comwrote: Thanks for checking it out Rob. Unfortunately did not work for me, and I again get the following: -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409757
Re: CLAP - restlet-jee-2.0snapshot
Hi, On Oct 20, 2009, at 10:46 AM, webp...@tigris.org wrote: Hi, is anyone there to help? Thanks! Dear All, I am using the restlet-jee-2.0snapshot, jdk5.0 on Tomcat 5.5. I have an application.properties file: WEB-INF/classes/application.properties But I keep getting the following error: java.lang.IllegalArgumentException: Cannot access to the configuration file: clap://system/WEB-INF/classes/ application.properties I haven't used CLAP myself, but I have a guess: if you're running in Tomcat, the classpath will include WEB-INF/classes. That means that resources (in the java sense) that you want to load need to be expressed relative to that directory; i.e., clap://system/ application.properties. Rhett It seems that I am not working properly with the classloader, CLAP. I have tried most ways, clap://thread/.., clap://class...but no luck so far. Here below is the code: Thanks, Sinoea [code] public class DirectoryServletApplication extends Application { /** Freemarker configuration object. */ private Configuration fmc; public static void main(String[] args) throws Exception { // Create a component Component component = new Component(); component.getServers().add(Protocol.HTTP, 8182); component.getClients().add(Protocol.FILE); component.getClients().add(Protocol.CLAP); component.getClients().add(Protocol.HTTP); DirectoryServletApplication application = new DirectoryServletApplication(component.getContext()); // Attach the application to the component and start it component.getDefaultHost().attach(, application); component.start(); } public DirectoryServletApplication(Context context) throws IOException { super(context); getConnectorService().getClientProtocols().add(Protocol.FILE); getConnectorService().getClientProtocols().add(Protocol.CLAP); getConnectorService().getClientProtocols().add(Protocol.HTTP); // Look for the configuration file in the classpath (Here is the PROBLEM) Properties properties = getProperties(clap://system/WEB-INF/ classes/application.properties); System.out.println(properties.get(web.root.path)); try { this.fmc = new Configuration(); final File templateDir = new File(C:\\Program Files\ \Apache Software Foundation\\Tomcat 5.5\\webapps\\directory\\ROOT\ \WEB-INF\\template); this.fmc.setDirectoryForTemplateLoading(templateDir); } catch (Exception e) { getLogger().severe(Unable to configure FreeMarker.); e.printStackTrace(); } } @Override public synchronized Restlet createInboundRoot() { // Create a router Restlet that routes each call to a // new instance of HelloWorldResource. Router router = new Router(getContext()); // Defines only one route router.attachDefault(HomePage.class); router.attach(/contactus, ContactUs.class); return router; } /** * Returns the freemarker configuration object. * * @return the freemarker configuration object. */ public Configuration getFmc() { return this.fmc; } /** * Returns a Properties instance loaded from the given URI. * * @param propertiesUri *The URI of the properties file. * @return A Properties instance loaded from the given URI. * @throws IOException */ public static Properties getProperties(String propertiesUri) throws IOException { Reference reference = new Reference(propertiesUri); Response response = new Client(reference.getSchemeProtocol()).get(reference); if (!(response.getStatus().isSuccess() response.isEntityAvailable())) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(Cannot access to the configuration file: \); stringBuilder.append(propertiesUri); stringBuilder.append(\); throw new IllegalArgumentException(stringBuilder.toString()); } Properties properties = new Properties(); properties.load(response.getEntity().getStream()); return properties; } } [/code] [code] ?xml version=1.0 encoding=UTF-8? web-app id=directory version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd display-namedirectory/display-name !-- Application class name -- context-param param-nameorg.restlet.application/param-name param-valueexample.DirectoryServletApplication/param-value /context-param context-param param-nameorg.restlet.clients/param-name param-valueHTTP HTTPS CLAP FILE/param-value
Re: Retrieving Login in a resource
Laurent, you can always calculate the MD5 hash on the server side, before trying to match the password with the one read from the database. There's no need to calculate it on the client at all. On Tue, Oct 20, 2009 at 12:40 PM, Laurent Garrigues laur...@speedinfo.fr wrote: Hello Jerome, First, thanks for your response, it resolve my issue. I use MD5 on the password because it is encrypt in MD5 in my database ( I know it's not very safe, but it's the directive of my manager). Kind regards Laurent Garrigues -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409413 -- Fabián Mandelbaum IS Engineer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409899
Ajax and Restlet
Hello, i am having trouble in communicating between the Reslet example from tutorial: First resource and my ajax client. When i look at the restlet log seems everithing ok, i get INFO: 2009-10-2118:47:35127.0.0.1 - - 8182 GET / - 200 12 - 19 http://localhost:8182 Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729) http://localhost/TutorialEST/Cruise2/Feder/RestTest2.html but in my ajax client i get as reponse status 0 what i dont undestand. Any ideas. The servlet code: http://www.restlet.org/documentation/1.1/firstResource my client code: function makePOSTRequest(method,url, parameters) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type http_request.overrideMimeType('text/xml'); //http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject(Msxml2.XMLHTTP); } catch (e) { try { http_request = new ActiveXObject(Microsoft.XMLHTTP); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; // http_request.open(method, url, true); if(method=='GET'){ http_request.open(method, url+parameters, true); http_request.setRequestHeader(Content-type, text/xml); http_request.setRequestHeader(Content-length, parameters.length); http_request.setRequestHeader(Connection, close); http_request.send(null); } -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409879
Router in servelet not routing to correct resource
Hello, I can't figure out why my router isn't routing to the correct resource. It always seems to route to the default route. I have 2 routes: router.attachDefault(DefaultResource.class); router.attach(/gpsh/test1,TestResource.class); My servlet container mapping: url-pattern/gpsh/*/url-pattern When I attempt to go to /gpsh/test1, I end up going to the default route. Any idea how I can get the routing corrected? Thanks, Matt -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409873
Re: Get secrets in resources
Hello, gonzajg a écrit : Is there a way to get the challengeresponse in resources? You should be able to get them in a ServerResource using ServerResource#getChallengeResponse() Then you could do a *getIdentifier()* and *getSecret()* Laurent. -- Laurent Rustuel, Alten contractor for Alcatel-Lucent, Brest -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409714
Re: Router in servelet not routing to correct resource
I'm not 100% sure based on that description, but try setting your second router line to: router.attach(/test1) On Oct 21, 2009, at 1:19 PM, Matt Stromske wrote: Hello, I can't figure out why my router isn't routing to the correct resource. It always seems to route to the default route. I have 2 routes: router.attachDefault(DefaultResource.class); router.attach(/gpsh/test1,TestResource.class); My servlet container mapping: url-pattern/gpsh/*/url-pattern When I attempt to go to /gpsh/test1, I end up going to the default route. Any idea how I can get the routing corrected? Thanks, Matt -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409873 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2409935