[opencms-dev] External Link to file in filesystem

Philip Kuegler mailinglists at pcom.at
Mon Oct 20 13:33:36 CEST 2008


Hi Manuel,

I'm not sure if you really want an absolute path or an URL. In either 
cases the "absolute" is want you want because it is including the full 
path to the resource from the filesystem root (that's in Unix/Linux "/" 
and on windows machines "c:\, d:\, e:\, ...").

Case1:
If you want to use it on the server only (this is independend of openCMS):
  1.) Create a File Object for the file on the disk
  2.) Call getAbsolutePath to get the absolute path on this machine 
(see: 
http://www.java2s.com/Tutorial/Java/0180__File/Absolutepathandrelativepath.htm)

Case2:
If you want to send it to the client (e.g. a web browser) you need to 
know some things first:
  *) What server should deliver the file (tomcat, resin, apache, boss, ...)
  *) Is the server(-application) allowed to deliver this file / does the 
server has access to the file?
  *) What is the servers name / What name should I use to generate the 
URL (or what IP)
  *) Do I have a "HttpServletRequest" object to get the domain name and 
servlet path from?

Case3:
If you want to create a URL for any resource within openCMS you can use 
CmsJspActionElement#link

br,
Philip

Manuel Wallnöfer wrote:
> Hi all,
>
> i want to create a external link to a file in the real file system on 
> the server where opencms runs.
>
> How is this possible ?
>
> for example to link to a file on drive L:/ of the server. ( 
> L://path/to/file/file.txt)
>
> Thanks for help !
>
> ~manuel
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>   




More information about the opencms-dev mailing list