[opencms-dev] Reading File in system folder

Frans Postma fpostma at xs4all.nl
Mon Mar 14 21:06:46 CET 2005


Hi,

It bugged me that ".." should work and usually does for me, so I looked it up :)
Seems readFile does expect fully specified VFS-filenames indeed. So in order to use relative links (which I usually prefer due to
being flexible), you should be able to do this:

CmsJspActionElement cms = new CmsJSPActionElement(pageContext, request, response);
CmsFile default_body = 
	cms.getCmsObject().readFile(cms.link("../default_bodies/my_default_body"));


Frans


> -----Original Message-----
> From: opencms-dev-bounces at opencms.org 
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of dno at archikart.de
> Sent: maandag 14 maart 2005 16:57
> To: opencms-dev at opencms.org
> Subject: Re:Re: [opencms-dev] Reading File in system folder
> 
> Hi Ronald,
> 
> Thanks. That work perfectly.
> 
> 
>   ----- Original Message ----- 
>   From: Ronald Lips 
>   To: The OpenCms mailing list 
>   Sent: Friday, March 11, 2005 10:40 AM
>   Subject: RE: [opencms-dev] Reading File in system folder
> 
> 
>   Hi Daniel,
> 
>   I think the line should be:
> 
>   CmsFile default_body = 
> cms.getCmsObject().readFile"/system/modules/mymodule/default_b
> odies/");
> 
>   regards
>   Ronald
> 
> 
> 
> 
> --------------------------------------------------------------
> ----------------
>   From: Daniel Noatnick [mailto:dno at archikart.de] 
>   Sent: vrijdag 11 maart 2005 10:19
>   To: opencms-dev at opencms.org
>   Subject: [opencms-dev] Reading File in system folder
> 
> 
>   Hallo group,
> 
>   I am a new user of opencms and I use opencms 6b1, Tomcat 
> 4.1.30, MySQL 4.0.23 on WinXP SP2. I have create a module, 
> and my site is located under  /sites/mysite/
>   In /system/modules/mymodule/elements/ is a JSP, which 
> should read the content of my default_body located in 
> /system/modules/mymodule/default_bodies/
> 
>   When I try to access my default_body, I get a 
> CmsVfsResourceNotFoundException.
>   Here is my code snippet from 
> /system/modules/mymodule/elements/read_content.jsp
> 
> 
>   CmsJspActionElement cms = new 
> CmsJSPActionElement(pageContext, request, response);
> 
>   CmsFile default_body = 
> cms.getCmsObject().readFile("../default_bodies/my_default_body");
> 
> 
>   Here I get this exception:
>   org.opencms.file.CmsVfsResourceNotFoundException: 
> [org.opencms.db.mysql.CmsVfsDriver.readResource/3] 
> /sites/mysite/../default_bodies/my_default_body [Code 2 - 
> Resource not found!]
> 
>   The read_content.jsp is included as a cms:template in my 
> default template.
> 
>   What is the right path to access my default body?
> 
>   Thanks a lot
> 
>   Daniel
> 
> 
> --------------------------------------------------------------
> ----------------
> 
> 
> 
> 
>   _______________________________________________
>   This mail is send to you from the opencms-dev mailing list
>   To change your list options, or to unsubscribe from the 
> list, please visit
>   http://mail.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list