RE: Re: access local file in tomcat container

2007-07-03 Thread Balas Julien
Thanks for the answer, the servletContextAdaptor completely filled my needs.

Best regards,
-- 
Julien Balas
JDAS Rennes 
-Message d'origine-
De : Thierry Boileau [mailto:[EMAIL PROTECTED] 
Envoyé : lundi 2 juillet 2007 22:58
À : discuss@restlet.tigris.org
Objet : Re: access local file in tomcat container

Hello Julien,

if you want to access files that are located inside your WebContent 
directory, you can use the integrated war client just as follow:
Representation rep =
getContext().getDispatcher().get(war:///files/file.xml).getEntity();
and then use the representation as you want.
NB: you can reuse parameters used for routing. For example, if your restlet has 
been reached according to the template
/segment/{myParameter}:
Representation rep =
getContext().getDispatcher().get(war:///files/file{myParameter}.xml).getEntity();

 What is the relationship between a restlet and a servlet ? none ?

The relation between a servlet and a restlet is made with the ServerServlet 
extension [1], and more precisely with the ServerServlet class which transmits 
servlet calls to your restlets, and the ServletContextAdapter that instantiates 
the war client and transmits all servlet context parameters to the restlet 
context parameters.

 Is there a way to get to javax.servlet.ServletContext from an 
 org.restlet.Application ?

Here is the way to get the servletContext:
ServletContextAdapter adapter = (ServletContextAdapter) getContext(); 
ServletContext servletContext = adapter.getServletContext();

Please feel free to ask for more details.

Best regards,
Thierry Boileau
[1]
http://www.restlet.org/documentation/1.0/ext/com/noelios/restlet/ext/servlet/package-summary.html


Re: access local file in tomcat container

2007-07-02 Thread Thierry Boileau

Hello Julien,

if you want to access files that are located inside your WebContent 
directory, you can use the integrated war client just as follow:
   Representation rep = 
getContext().getDispatcher().get(war:///files/file.xml).getEntity();

and then use the representation as you want.
NB: you can reuse parameters used for routing. For example, if your 
restlet has been reached according to the template 
/segment/{myParameter}:
   Representation rep = 
getContext().getDispatcher().get(war:///files/file{myParameter}.xml).getEntity();



What is the relationship between a restlet and a servlet ? none ?

The relation between a servlet and a restlet is made with the 
ServerServlet extension [1], and more precisely with the ServerServlet 
class which transmits servlet calls to your restlets, and the 
ServletContextAdapter that instantiates the war client and transmits all 
servlet context parameters to the restlet context parameters.


Is there a way to get to javax.servlet.ServletContext from an 
org.restlet.Application ?



Here is the way to get the servletContext:
ServletContextAdapter adapter = (ServletContextAdapter) getContext();
ServletContext servletContext = adapter.getServletContext();

Please feel free to ask for more details.

Best regards,
Thierry Boileau
[1] 
http://www.restlet.org/documentation/1.0/ext/com/noelios/restlet/ext/servlet/package-summary.html


access local file in tomcat container

2007-06-28 Thread Balas Julien
Hi,

[note : I'm new to rest and restlet so my terminology may be not very good]
I've created a rest service using restlet, it's working great when I use the 
integrated webserver.
When I try to use my restlet in tomcat, it fail because it can't read a file on 
the disk.

My class is called, with the right parameters extracted from the URL, so the 
mechanism seems to work.

In my restlet I'm doing things like 
new File(/resources/schemas/blabla.xsd)

But in tomcat, I get this error
\resources\schemas\blabla.xsd (Le chemin d'accès spécifié est introuvable) 
[file not found in French]

How can I find the physical name of a file in a restlet served by tomcat ?
What is the relationship between a restlet and a servlet ? none ?

Is there a way to get to
javax.servlet.ServletContext 
from an 
org.restlet.Application ?

Best Regards,
-- 
Julien Balas
JDAS Rennes