On 14 Jan 2008, at 15:40, Romain Slootmaekers wrote:

Robin Wyles wrote:
Hi Romain,

On 14 Jan 2008, at 13:40, Romain Slootmaekers wrote:

Hi,

I've been trying to use map:read to read a file from a location on the fs outside the cocoon root.

http://cocoon.apache.org/2.2/core-modules/core/2.2/846_1_1.html
is rather sparse, but I tried:

<map:match  pattern="**.msi">
               <map:read type="resource"
                   src="installer.msi"
                   mime-type="application/octet-stream" />
</map:match>


and alternatives with ../ ./ / aso. nothing seems to work with mvn jetty:run-war)

The question is: can I use map:read for this, or need I write a little servlet ?


I think you should be able to, have you tried using an absolute path to the file like so?

 <map:read type="resource"
                   src="/absolute/path/to/your/file/installer.msi"
                   mime-type="application/octet-stream" />

Yes the file:///C:/some path/installer.msi works

but I would like to have a relative path as the app needs to be relocatable

Relative paths are resolved relative to the location of the sitemap, and in C2.2 the location of the sitemap varies greatly depending on how you run cocoon during development, deployment etc. In your production webapp your sitemap will be in the jar file created for your block.

You could use the directory generator [1] along with ../ in your src attribute to determine how the relative paths are resolved.

I would suggest you try to determine the absolute path to your webapp context first and then resolve your path relative to that, you might want to take a look at using the ContextPathModule [2] which could help you.

Robin

[1] http://cocoon.apache.org/2.2/core-modules/core/2.2/953_1_1.html
[2] http://cocoon.apache.org/2.1/userdocs/concepts/modules-ref.html (These are the docs for C2.1, I don't think the comparable documentation for C2.2 exists yet, but they should work in the same way.)




Romain.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to