Writing files accessible from a browser

2006-08-07 Thread Romain Quilici
Hi all, I have been reading several messages about writing files inside a web application, but I found no answer regarding my problem. I need to write files on the file system that can be accessible with a browser(I write images). - The most reliable solution I found was to use the webapp's

Re: Writing files accessible from a browser

2006-08-07 Thread Li
if you have apache server, you can write file to its home dir, and then use http://youdomain/image_dir/image_name.suffix to view. On 8/7/06, Romain Quilici [EMAIL PROTECTED] wrote: Hi all, I have been reading several messages about writing files inside a web application, but I found no answer

Re: Writing files accessible from a browser

2006-08-07 Thread Romain Quilici
Thanks for the answer, this solution was part of my investigation, and was actually the first idea I had. The problem with this approach is I don't know how to access the /image_dir/ from within my web application. Maybe using something like String path = servletContext.getRealPath(/); String

Re: Writing files accessible from a browser

2006-08-07 Thread Li
Hi, Here are few steps of achieving it (just tested, and it works): 1. use FileOutputStream or any output streaming object to write a image file into the directory in Windows, the path string should look like: c:\apache_home\httpdocs\images\1.jpg in unix/linux, the path should look like

Re: Writing files accessible from a browser

2006-08-07 Thread Romain Quilici
Hi, thanks for the advice, But I want to avoid harcoded links such as $APACHE_HOME\httpdocs\images or a href=http://yourdomain/images/1.jpg; in my jsp. Indeed I don't want to modify these values if I decide Tomcat to run on another port, or to install Tomcat in another directory or even OS.

Re: Writing files accessible from a browser

2006-08-07 Thread Li
Hi, It is not advisable to make your webapp dir writable, can you tell me what exactly would you like to achieve so that I may get more info to help out ... On 8/7/06, Romain Quilici [EMAIL PROTECTED] wrote: Hi, thanks for the advice, But I want to avoid harcoded links such as

Re: Writing files accessible from a browser

2006-08-07 Thread Romain Quilici
Hi, Hope I will be clear enough: One part of my web application receives encodes stream that it has to convert to jpg images. When an image is written on the server, it notifies a Servlet which pushes the name (or the url) of the newly generated image inside client browser(thanks to

Re: Writing files accessible from a browser

2006-08-07 Thread Almir Kazazic
Hi, to avoid using absolut paths you can find that out on runtime by getContext().getRealPath(/) - will return your path to the root regards On 8/7/06, Romain Quilici [EMAIL PROTECTED] wrote: Hi, Hope I will be clear enough: One part of my web application receives encodes stream that it

Re: Writing files accessible from a browser

2006-08-07 Thread Romain Quilici
I agree with you, but getContext().getRealPath(/), will return the path to my webapp root, so it means I am going to create my image dir under my webapp, which is fine unless my application is deployed in a war file. In such case I won't be able to write in my webapp. Maybe using String path =

Re: Writing files accessible from a browser

2006-08-07 Thread Almir Kazazic
Oh I see, something like that , i do not think taht this will work String imagePath = path+../imagedir; but you will have to either convert path to instance of directory object, or chop of the end by some string functions , using String imagePath = path+../imagedir; as path works for browser

Re: Writing files accessible from a browser

2006-08-07 Thread Mohsen Saboorian
You can use a servlet init param inside web.xml for avoiding hardcoded solutions. e.g. context-param param-nameMY_PATH/param-name param-valuec:\my\path\to\imgs/param-value /context-param On 8/7/06, Romain Quilici [EMAIL PROTECTED] wrote: Hi, Hope I will be clear enough: One part of my web

RE: Writing files accessible from a browser

2006-08-07 Thread Tim Lucia
:[EMAIL PROTECTED] Sent: Monday, August 07, 2006 5:32 AM To: Tomcat Users List Subject: Re: Writing files accessible from a browser You can use a servlet init param inside web.xml for avoiding hardcoded solutions. e.g. context-param param-nameMY_PATH/param-name param-valuec:\my\path\to\imgs

Re: Writing files accessible from a browser

2006-08-07 Thread Moises Lejter
I had a similar question, earlier... There is another issue here: you are right that WAR files are expanded back into a folder - at least by default - so one could still create a folder within the web app to write to, and which is visible to browsers... Until one deploys an updated WAR file.

Re: Writing files accessible from a browser

2006-08-07 Thread Len Popp
So, you need a directory where you can write files and serve them to the web, and you don't want that directory to be hard-coded in your application. First, you need a way to specify the directory when the app is installed. (In general your app may need a bunch of configuration settings.) There

Re: Writing files accessible from a browser

2006-08-07 Thread Li
you are right Moises, if you really wanna write to somewhere within the webapp deploy folder, a better is to make a soft symbol link point to the directory that stores the image, catalina_home/webapps --- your_web image_dir --- /tmp/images/ so next time

Re: Writing files accessible from a browser

2006-08-07 Thread Romain Quilici
Hi all, thanks a lot for all solutions proposed. I think I am going create the directory within my webapp, but without symbolic link, as my images are temporary files. So even if the directory is deleted it really does not matter Thanks again Romain Li wrote: you are right Moises, if you