cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carsten Ziegeler <cziege...@apache.org>
Subject Re: cocoon.context.getRealPath & cocoon 2.2
Date Tue, 22 Jan 2008 17:08:14 GMT
Reinhard Poetz wrote:
> anil wrote:
>> Hi -
>>
>> Just to update this posting with my investigations - I've managed to 
>> extract
>> the file contents within my spring bean.
>>
>> The basic problem was the way I was creating the file object - the path
>> returned by the cocoon.context.getRealPath() method was a URI & when
>> instantiating my File object I needed to create a URI object first.
>>
>> Therefore it was:
>>
>> URI fileURI = new URI("<output of cocoon.context.getRealPath>");
>> File file = new File(fileURI);
>>
>> rather than just new File("<output of cocoon.context.getRealPath>");
>>
>> Sorry - I should have noticed this - I assumed that I should be able 
>> to pass
>> the abstract path into File object directly - I blame it on the late 
>> nights!
>>
>> One thing I still don't really understand though is that I'm still 
>> unable to
>> get a path to the resource that I want to access through my spring 
>> bean as
>> cocoon.context.getRealPath("xqy/test.xqy") still returns null. In 
>> order to
>> get round this I do:
>>
>> var fullPath = cocoon.context.getRealPath("/") + "xqy/test.xqy";
>>
>> If anyone could clear up that confusion I'd be very grateful.
> 
> Just wondering: Why can't you use the source resolver?
> 
getRealPath() on the context is mapped to the getRealPath of the servlet 
context. The method is described as follows:
"Returns aString containing the real path for a given virtual path. For 
example, the path “/index.html” returns the absolute file path on the 
server’s file-system would be served by a request for 
“http://host/contextPath/index.html”,
where contextPath is the context path of this ServletContext."

Now I guess that you want to get the resource so if you would use the 
servlet context, the getResource() method would be the right choice.
In Cocoon it's, as Reinhard suggested, the source resolver you should use.

Carsten


-- 
Carsten Ziegeler
cziegeler@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message