Hi Luis,

it should work if you attach the directory like this (please note the removes trailing "/"):

Directory docsDir = new Directory(getContext(), "war:///doc");
docsDir.setNegotiateContent(false);
docsDir.setIndexName("index.html");
router.attach("/doc", docsDir);


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org <http://www.restlet.org/>
Noelios Technologies ~ Co-founder ~ http://www.noelios.com <http://www.noelios.com/>
Hi Jerome,

Thanks for the suggestion.

I tried it, but unfortunately that didn't work either. The explicit URL
still works, but the index file is still not served when you access the
parent URL.

Let me know if you have any other ideas or if you think this is due to a
bug. Thanks again!

    - Lu


-----Original Message-----
From: Jerome Louvel [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 2:03 AM
To: [email protected]
Subject: RE: serving static files from servlet WAR with Directory class:
index.html not served automatically


Hi Luis,

This is due to the fact that directory listing isn't possible with the
war:// client connector, as opposed to the file:// client.

However, could you try this:

      // expose static API docs
      Directory docsDir = new Directory(getContext(), "war:///doc");
        docsDir.setNegotiateContent(false);
        docsDir.setIndexName("index.html");
      router.attach("/doc/", docsDir);

Let us know if this doesn't solve your issue and we'll look at the code.

Best regards,
Jérôme Louvel

PS: No problem for the HTML mail, I think most people can read them fine.
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoyé : mercredi 8 octobre 2008 01:25
À : [email protected]
Objet : serving static files from servlet WAR with Directory class:
index.html not served automatically

(Apologies for my previous non-text email; trying again.)

I'm using restlet 1.1-RC2 with the ServerServlet extension on Oracle AS
10.1.3 with the web.xml configuration method.

I was able to successfully serve static files (included in the
'webapp/doc' directory within the WAR) using an instance of the Directory
class, as follows:

      // expose static API docs
      Directory docsDir = new Directory(getContext(), "war:///doc");
      router.attach("/doc/", docsDir);

My problem, however, is that the 'index.html' file within the 'webapp/doc'
folder is not served automatically by the NRE when I use the following URL
(instead the server returns 404):

      http://abc.com/mywar/doc

But it does work when I use the following explicit URL:

      http://abc.com/mywar/doc/index.html

Is there a configuration that needs to be set so that the Directory class
will return the index file when a parent URL is accessed? Using log
output, I have verified that Directory.getIndexName() does in fact return
"index".

Does anyone have a solution? Thanks,

    - Lu

Reply via email to