Hello John, 1. yes, you can use the init-param, and context-param, they are copied into the Context of the application. You can call Context#getParameters to retrieve them.
2. Exactly, there is no difference between the code of the standalone application and the servlet hosted one. 3. well, if the static files are not supposed to be located inside the war application, you can use the "FILE" connector. From your application, you send a "file:///path/to/my/file", and you will get it. In order to make this run properly, you need to declare the "FILE"connector (see http://wiki.restlet.org/docs_2.0/13-restlet/379-restlet.html") and ensure this "FILE" connector is located in the classpath. As it is part of the core module (org.restlet.jar), there is no worry about it. If the static files are supposed to be located in the war, you can use the "WAR" connector (shipped with the org.restlet.ext.servlet extension, no need to declare it), and issue calls like "war:///path/to/my/file" I hope I answer your questions. Best regards, Thierry Boileau > I have an application that runs, not continuously but as a daily job, so > I'll call it "the job" for clarity. I have added a Restlet service to the > job to serve a dynamically generated web page showing the job's current > status while it is running. This works well, but of course it shows nothing > after the job terminates. When the job terminates, it writes a static HTML > file with its final status to a directory. > > What I'd like to do now is write a separate Restlet application providing a > service that does this: > > 1. First tries to connect to the Restlet service in the running job, and > returns the status it gets if it succeeds. > 2. If it fails to connect because the job is not running, it returns the > static HTML file that the most recent run of the job wrote out as it > terminated. > > I can read the static file directly from the file system and return it as a > StringReprsentation. This simplifies my code since I do not need a separate > Directory service to serve the file. It also obviates the question I had > about the URL to use to do this. > > I know that I can use a ClientResource to call the service that is part of > the running job. If the connection fails, I can detect that by catching a > ResourceException with a Status of 1001. That is the signal to return the > static file instead. > > It would be nice if this new application could run in a servlet container > such as Tomcat, but I might be able to run it as a standalone application if > necessary. I have a general idea how to do this, but I am unsure of some of > the details. Part of my problem is that it has been a long time since I > have written a servlet or used a servlet container. I looked at the example > in the old 1.0 FAQ, which helps some. Here are my questions. > > 1. It would be nice to provide the URL of the job's service through > parameters or properties of some sort rather than hard coding it. I am > guessing that the attributes map in the Restlet's Context could hold it. > The question is how I get it there if I run the service in Tomcat. Could I > put it in the web.xml file as a context-param? Is there a better way? > > 2. The TestServletApplication example from the FAQ is an Application having > as an inbound root a Restlet that overrides handle directly. All the other > examples I have done have been based on those from the Restlet tutorial > where I use a main class to set up an Application with an inbound root as a > Router to which I can attach subclasses of ServerResource that I write. I > hope that approach will work here. > > 3. Just for fun, the question I bypassed by directly reading the file is > what sort of URL I would use to read the HTML file from a Directory > service. Would a "root-relative" URL such as "/statusfiles/laststatus.html" > work? If the service is running in Tomcat, would I need to use the servlet > prefix in the URL, or just the part that begins at the restlet level? I > know that I don't really need to do this now, but I'm still curious about > having the restlet call itself. > > Any thoughts or suggestions would be appreciated. > > Thanks, > John > > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2704841

