You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Romain Quilici <r....@chem.usyd.edu.au> on 2006/08/07 08:14:50 UTC
Writing files accessible from a browser
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 tmp
directory, unfortunately this directory is not accessible with a URL.
- Another solution would be to write these images under my webapp
root(or in another place under my webapp). But it seems that this
approach does not work with webapps deployed in a war file.
Indeed you cannot write inside wars like this.
I don't want to rely on some hardcoded solutions. There is still the
possibility to pass the absolute path to the directory (let's say
TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
<request.getContextPath()/../myimages/image1.jpg>, but I think this
solution won't work in many configurations
Thanks a lot for your help
Regards
Romain
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Romain Quilici <r....@chem.usyd.edu.au>.
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 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 update the war, even the folder is removed, the images
> still at /tmp
> we can just make a new <image_dir> and make a new link that points to
> /tmp/images
> whenever image needs to be written to ...
>
> On 8/7/06, Moises Lejter <ml...@teamsoftinc.com> wrote:
>> 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.
>> At that
>> point, tomcat will delete the old expanded WAR folder, in order to
>> create a
>> new one to deploy the new WAR file into - and in the process it will
>> remove
>> all files that were created before. If these files are just transient
>> anyway, then it does not matter...
>>
>> Moises
>>
>> "Li" <am...@gmail.com> wrote in message
>> news:c197ef590608070130g6d42edc0hf27aaf8eae8748bf@mail.gmail.com...
>> >
>> > 1. even you deploy as war, later after start tomcat, it will still
>> > generate a folder that actually tomcat uses normally. so in this case,
>> > you still be able to use context path to write
>> > 3. to write, you can always use context path or absolute path
>> > defintion no matter is inside or outside, but after been written and
>> > you wanna view, you have to define as URL,
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Li <am...@gmail.com>.
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 update the war, even the folder is removed, the images
still at /tmp
we can just make a new <image_dir> and make a new link that points to
/tmp/images
whenever image needs to be written to ...
On 8/7/06, Moises Lejter <ml...@teamsoftinc.com> wrote:
> 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. At that
> point, tomcat will delete the old expanded WAR folder, in order to create a
> new one to deploy the new WAR file into - and in the process it will remove
> all files that were created before. If these files are just transient
> anyway, then it does not matter...
>
> Moises
>
> "Li" <am...@gmail.com> wrote in message
> news:c197ef590608070130g6d42edc0hf27aaf8eae8748bf@mail.gmail.com...
> >
> > 1. even you deploy as war, later after start tomcat, it will still
> > generate a folder that actually tomcat uses normally. so in this case,
> > you still be able to use context path to write
> > 3. to write, you can always use context path or absolute path
> > defintion no matter is inside or outside, but after been written and
> > you wanna view, you have to define as URL,
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
When we invent time, we invent death.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Moises Lejter <ml...@teamsoftinc.com>.
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. At that
point, tomcat will delete the old expanded WAR folder, in order to create a
new one to deploy the new WAR file into - and in the process it will remove
all files that were created before. If these files are just transient
anyway, then it does not matter...
Moises
"Li" <am...@gmail.com> wrote in message
news:c197ef590608070130g6d42edc0hf27aaf8eae8748bf@mail.gmail.com...
>
> 1. even you deploy as war, later after start tomcat, it will still
> generate a folder that actually tomcat uses normally. so in this case,
> you still be able to use context path to write
> 3. to write, you can always use context path or absolute path
> defintion no matter is inside or outside, but after been written and
> you wanna view, you have to define as URL,
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Li <am...@gmail.com>.
hi,
1. even you deploy as war, later after start tomcat, it will still
generate a folder that actually tomcat uses normally. so in this case,
you still be able to use context path to write
2. if you wanna avoid other people modiy, you can create script/IO
stream object that generates folder before you write to.
3. to write, you can always use context path or absolute path
defintion no matter is inside or outside, but after been written and
you wanna view, you have to define as URL, have you tried use
file:\\???\??? or use some JVM properties attribute. That may help you
define a OS independent path.
Wish those helps
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Almir Kazazic <ka...@gmail.com>.
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 but I am
not shure about filesystem
regards
On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> 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 = getContext().getRealPath("/");
> then
> String imagePath = path+"../imagedir"; would work so I am writting in a
> separate directory outside my webapp. In case I use war file, this
> solution might still works
> Regards
>
> Almir Kazazic wrote:
> > 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 <r....@chem.usyd.edu.au> wrote:
> >> 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 pushlets technology).
> >> The Servlet can only push a String (Pushlets requirements).
> >>
> >> So my problem is where can I write the images, so they can be accessible
> >> by a URL. One easy solution, the one I use for testing, is to hardcode
> >> in my webapp the directory where the images are written.
> >> For instance TOMCAT_HOME\webapps\frames\,
> >> and in my jsp to have <img src="http://myserver/frames/name.jpg> where
> >> name.jpg is pushed by the servlet when this image is generated.
> >>
> >> However, this solution is not satisfactory, indeed, if I deploy my
> >> application in another place, I don't want people to edit my code to
> >> change for suitable values. I admit I could use properties or a
> >> configuration file to set these value(even if I am not sure it would
> >> work in all configuration), anyway I would like to check if using the
> >> servletcontext, or other solutions might be more appropriate.
> >> As I said a solution with the temp directory would be perfect, if this
> >> directory was accessible with a URL
> >>
> >> Hope it is clear
> >> Regards
> >> Li wrote:
> >> > 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 <r....@chem.usyd.edu.au> wrote:
> >> >> 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. That
> >> >> is why I am looking for an approach using
> >> >> the webapp context, so I don't have to worry about the OS, or the
> >> port,
> >> >> or whatever configuration.
> >> >> Anyway thanks for your help
> >> >> Regards
> >> >> Romain
> >> >>
> >> >> Li wrote:
> >> >> > 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
> >> >> > $APACHE_HOME\httpdocs\images\1.jpg"
> >> >> > (assume, you had defined APACHE_HOME, make sure the images folder
> >> >> > is read/write
> >> >> > only for the user/group that runs tomcat
> >> >> > 2. Make sure apache is on ...
> >> >> > 3. in your jsp: use
> >> >> > e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
> >> >> >
> >> >> >
> >> >> > Wish it helps
> >> >> >
> >> >> > On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> >> >> >> 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 imagePath = path+"../image_dir/"
> >> >> >> and use the imagePath to create my images, then in my jsp
> >> >> something like
> >> >> >> <request.getContextPath()/../image_dir/image1.jpg>
> >> >> >>
> >> >> >> But I am not sure this approach works in all configurations,
> >> >> >> particularly if my webapp is deployed inside a war.
> >> >> >>
> >> >> >> Thanks
> >> >> >> Romain
> >> >> >>
> >> >> >> Li wrote:
> >> >> >> > 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 <r....@chem.usyd.edu.au> wrote:
> >> >> >> >> 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
> >> tmp
> >> >> >> >> directory, unfortunately this directory is not accessible with
> >> >> a URL.
> >> >> >> >>
> >> >> >> >> - Another solution would be to write these images under my
> >> webapp
> >> >> >> >> root(or in another place under my webapp). But it seems that
> >> this
> >> >> >> >> approach does not work with webapps deployed in a war file.
> >> >> >> >> Indeed you cannot write inside wars like this.
> >> >> >> >>
> >> >> >> >> I don't want to rely on some hardcoded solutions. There is
> >> >> still the
> >> >> >> >> possibility to pass the absolute path to the directory
> >> (let's say
> >> >> >> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
> >> >> >> >> <request.getContextPath()/../myimages/image1.jpg>, but I think
> >> >> this
> >> >> >> >> solution won't work in many configurations
> >> >> >> >>
> >> >> >> >> Thanks a lot for your help
> >> >> >> >> Regards
> >> >> >> >> Romain
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Romain Quilici <r....@chem.usyd.edu.au>.
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 = getContext().getRealPath("/");
then
String imagePath = path+"../imagedir"; would work so I am writting in a
separate directory outside my webapp. In case I use war file, this
solution might still works
Regards
Almir Kazazic wrote:
> 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 <r....@chem.usyd.edu.au> wrote:
>> 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 pushlets technology).
>> The Servlet can only push a String (Pushlets requirements).
>>
>> So my problem is where can I write the images, so they can be accessible
>> by a URL. One easy solution, the one I use for testing, is to hardcode
>> in my webapp the directory where the images are written.
>> For instance TOMCAT_HOME\webapps\frames\,
>> and in my jsp to have <img src="http://myserver/frames/name.jpg> where
>> name.jpg is pushed by the servlet when this image is generated.
>>
>> However, this solution is not satisfactory, indeed, if I deploy my
>> application in another place, I don't want people to edit my code to
>> change for suitable values. I admit I could use properties or a
>> configuration file to set these value(even if I am not sure it would
>> work in all configuration), anyway I would like to check if using the
>> servletcontext, or other solutions might be more appropriate.
>> As I said a solution with the temp directory would be perfect, if this
>> directory was accessible with a URL
>>
>> Hope it is clear
>> Regards
>> Li wrote:
>> > 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 <r....@chem.usyd.edu.au> wrote:
>> >> 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. That
>> >> is why I am looking for an approach using
>> >> the webapp context, so I don't have to worry about the OS, or the
>> port,
>> >> or whatever configuration.
>> >> Anyway thanks for your help
>> >> Regards
>> >> Romain
>> >>
>> >> Li wrote:
>> >> > 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
>> >> > $APACHE_HOME\httpdocs\images\1.jpg"
>> >> > (assume, you had defined APACHE_HOME, make sure the images folder
>> >> > is read/write
>> >> > only for the user/group that runs tomcat
>> >> > 2. Make sure apache is on ...
>> >> > 3. in your jsp: use
>> >> > e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
>> >> >
>> >> >
>> >> > Wish it helps
>> >> >
>> >> > On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
>> >> >> 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 imagePath = path+"../image_dir/"
>> >> >> and use the imagePath to create my images, then in my jsp
>> >> something like
>> >> >> <request.getContextPath()/../image_dir/image1.jpg>
>> >> >>
>> >> >> But I am not sure this approach works in all configurations,
>> >> >> particularly if my webapp is deployed inside a war.
>> >> >>
>> >> >> Thanks
>> >> >> Romain
>> >> >>
>> >> >> Li wrote:
>> >> >> > 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 <r....@chem.usyd.edu.au> wrote:
>> >> >> >> 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
>> tmp
>> >> >> >> directory, unfortunately this directory is not accessible with
>> >> a URL.
>> >> >> >>
>> >> >> >> - Another solution would be to write these images under my
>> webapp
>> >> >> >> root(or in another place under my webapp). But it seems that
>> this
>> >> >> >> approach does not work with webapps deployed in a war file.
>> >> >> >> Indeed you cannot write inside wars like this.
>> >> >> >>
>> >> >> >> I don't want to rely on some hardcoded solutions. There is
>> >> still the
>> >> >> >> possibility to pass the absolute path to the directory
>> (let's say
>> >> >> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
>> >> >> >> <request.getContextPath()/../myimages/image1.jpg>, but I think
>> >> this
>> >> >> >> solution won't work in many configurations
>> >> >> >>
>> >> >> >> Thanks a lot for your help
>> >> >> >> Regards
>> >> >> >> Romain
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> ---------------------------------------------------------------------
>> >> >> >> To start a new topic, e-mail: users@tomcat.apache.org
>> >> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> >> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To start a new topic, e-mail: users@tomcat.apache.org
>> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To start a new topic, e-mail: users@tomcat.apache.org
>> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> >> For additional commands, e-mail: users-help@tomcat.apache.org
>> >>
>> >>
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Almir Kazazic <ka...@gmail.com>.
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 <r....@chem.usyd.edu.au> wrote:
> 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 pushlets technology).
> The Servlet can only push a String (Pushlets requirements).
>
> So my problem is where can I write the images, so they can be accessible
> by a URL. One easy solution, the one I use for testing, is to hardcode
> in my webapp the directory where the images are written.
> For instance TOMCAT_HOME\webapps\frames\,
> and in my jsp to have <img src="http://myserver/frames/name.jpg> where
> name.jpg is pushed by the servlet when this image is generated.
>
> However, this solution is not satisfactory, indeed, if I deploy my
> application in another place, I don't want people to edit my code to
> change for suitable values. I admit I could use properties or a
> configuration file to set these value(even if I am not sure it would
> work in all configuration), anyway I would like to check if using the
> servletcontext, or other solutions might be more appropriate.
> As I said a solution with the temp directory would be perfect, if this
> directory was accessible with a URL
>
> Hope it is clear
> Regards
> Li wrote:
> > 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 <r....@chem.usyd.edu.au> wrote:
> >> 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. That
> >> is why I am looking for an approach using
> >> the webapp context, so I don't have to worry about the OS, or the port,
> >> or whatever configuration.
> >> Anyway thanks for your help
> >> Regards
> >> Romain
> >>
> >> Li wrote:
> >> > 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
> >> > $APACHE_HOME\httpdocs\images\1.jpg"
> >> > (assume, you had defined APACHE_HOME, make sure the images folder
> >> > is read/write
> >> > only for the user/group that runs tomcat
> >> > 2. Make sure apache is on ...
> >> > 3. in your jsp: use
> >> > e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
> >> >
> >> >
> >> > Wish it helps
> >> >
> >> > On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> >> >> 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 imagePath = path+"../image_dir/"
> >> >> and use the imagePath to create my images, then in my jsp
> >> something like
> >> >> <request.getContextPath()/../image_dir/image1.jpg>
> >> >>
> >> >> But I am not sure this approach works in all configurations,
> >> >> particularly if my webapp is deployed inside a war.
> >> >>
> >> >> Thanks
> >> >> Romain
> >> >>
> >> >> Li wrote:
> >> >> > 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 <r....@chem.usyd.edu.au> wrote:
> >> >> >> 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 tmp
> >> >> >> directory, unfortunately this directory is not accessible with
> >> a URL.
> >> >> >>
> >> >> >> - Another solution would be to write these images under my webapp
> >> >> >> root(or in another place under my webapp). But it seems that this
> >> >> >> approach does not work with webapps deployed in a war file.
> >> >> >> Indeed you cannot write inside wars like this.
> >> >> >>
> >> >> >> I don't want to rely on some hardcoded solutions. There is
> >> still the
> >> >> >> possibility to pass the absolute path to the directory (let's say
> >> >> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
> >> >> >> <request.getContextPath()/../myimages/image1.jpg>, but I think
> >> this
> >> >> >> solution won't work in many configurations
> >> >> >>
> >> >> >> Thanks a lot for your help
> >> >> >> Regards
> >> >> >> Romain
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Len Popp <le...@gmail.com>.
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 are various places that you can put these settings -
<context-param> in web.xml, a config file read by the webapp, a
database table, etc. The way that your servlets and JSP pages access
these settings depends on how they're stored.
In my app, I store these settings in the database, and set up a
variable so that image files are specified in JSP as
"${imageFiles}/image1.jpg", which comes out as
"/appfiles/images/image1.jpg" (or whatever).
Then, when the app is installed and configured, the admin has to set
up a directory that is writable by Tomcat, and is published on the
web. For stand-alone Tomcat, this can be a directory in the ROOT
webapp, e.g. $CATALINA_BASE/ROOT/appfiles/images. If Tomcat is fronted
by a web server, the image files could be served by the web server.
The admin has to set two settings for your app: the URL to access the
directory (e.g. "/appfiles/images") and the file system pathname for
the same directory, so you know where to write the files (e.g.
"$CATALINA_BASE/ROOT/appfiles/images").
Hope this helps.
--
Len
On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> 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 pushlets technology).
> The Servlet can only push a String (Pushlets requirements).
>
> So my problem is where can I write the images, so they can be accessible
> by a URL. One easy solution, the one I use for testing, is to hardcode
> in my webapp the directory where the images are written.
> For instance TOMCAT_HOME\webapps\frames\,
> and in my jsp to have <img src="http://myserver/frames/name.jpg> where
> name.jpg is pushed by the servlet when this image is generated.
>
> However, this solution is not satisfactory, indeed, if I deploy my
> application in another place, I don't want people to edit my code to
> change for suitable values. I admit I could use properties or a
> configuration file to set these value(even if I am not sure it would
> work in all configuration), anyway I would like to check if using the
> servletcontext, or other solutions might be more appropriate.
> As I said a solution with the temp directory would be perfect, if this
> directory was accessible with a URL
>
> Hope it is clear
> Regards
> Li wrote:
> > 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 <r....@chem.usyd.edu.au> wrote:
> >> 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. That
> >> is why I am looking for an approach using
> >> the webapp context, so I don't have to worry about the OS, or the port,
> >> or whatever configuration.
> >> Anyway thanks for your help
> >> Regards
> >> Romain
> >>
> >> Li wrote:
> >> > 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
> >> > $APACHE_HOME\httpdocs\images\1.jpg"
> >> > (assume, you had defined APACHE_HOME, make sure the images folder
> >> > is read/write
> >> > only for the user/group that runs tomcat
> >> > 2. Make sure apache is on ...
> >> > 3. in your jsp: use
> >> > e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
> >> >
> >> >
> >> > Wish it helps
> >> >
> >> > On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> >> >> 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 imagePath = path+"../image_dir/"
> >> >> and use the imagePath to create my images, then in my jsp
> >> something like
> >> >> <request.getContextPath()/../image_dir/image1.jpg>
> >> >>
> >> >> But I am not sure this approach works in all configurations,
> >> >> particularly if my webapp is deployed inside a war.
> >> >>
> >> >> Thanks
> >> >> Romain
> >> >>
> >> >> Li wrote:
> >> >> > 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 <r....@chem.usyd.edu.au> wrote:
> >> >> >> 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 tmp
> >> >> >> directory, unfortunately this directory is not accessible with
> >> a URL.
> >> >> >>
> >> >> >> - Another solution would be to write these images under my webapp
> >> >> >> root(or in another place under my webapp). But it seems that this
> >> >> >> approach does not work with webapps deployed in a war file.
> >> >> >> Indeed you cannot write inside wars like this.
> >> >> >>
> >> >> >> I don't want to rely on some hardcoded solutions. There is
> >> still the
> >> >> >> possibility to pass the absolute path to the directory (let's say
> >> >> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
> >> >> >> <request.getContextPath()/../myimages/image1.jpg>, but I think
> >> this
> >> >> >> solution won't work in many configurations
> >> >> >>
> >> >> >> Thanks a lot for your help
> >> >> >> Regards
> >> >> >> Romain
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Writing files accessible from a browser
Posted by Tim Lucia <ti...@yahoo.com>.
One solution which is often mentioned to this question is to return a URL to
a servlet which knows how to generate the .jpg image as its response. Set
the context type appropriately, and write the JPEG bytes to the output
stream.
Tim
> -----Original Message-----
> From: Mohsen Saboorian [mailto:mohsens@gmail.com]
> 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-name>MY_PATH</param-name>
> <param-value>c:\my\path\to\imgs</param-value>
> </context-param>
>
>
> On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> > 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 pushlets technology).
> > The Servlet can only push a String (Pushlets requirements).
> >
> > So my problem is where can I write the images, so they can be accessible
> > by a URL. One easy solution, the one I use for testing, is to hardcode
> > in my webapp the directory where the images are written.
> > For instance TOMCAT_HOME\webapps\frames\,
> > and in my jsp to have <img src="http://myserver/frames/name.jpg> where
> > name.jpg is pushed by the servlet when this image is generated.
> >
> > However, this solution is not satisfactory, indeed, if I deploy my
> > application in another place, I don't want people to edit my code to
> > change for suitable values. I admit I could use properties or a
> > configuration file to set these value(even if I am not sure it would
> > work in all configuration), anyway I would like to check if using the
> > servletcontext, or other solutions might be more appropriate.
> > As I said a solution with the temp directory would be perfect, if this
> > directory was accessible with a URL
> >
> > Hope it is clear
> > Regards
> > Li wrote:
> > > 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 <r....@chem.usyd.edu.au> wrote:
> > >> 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.
> That
> > >> is why I am looking for an approach using
> > >> the webapp context, so I don't have to worry about the OS, or the
> port,
> > >> or whatever configuration.
> > >> Anyway thanks for your help
> > >> Regards
> > >> Romain
> > >>
> > >> Li wrote:
> > >> > 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
> > >> > $APACHE_HOME\httpdocs\images\1.jpg"
> > >> > (assume, you had defined APACHE_HOME, make sure the images folder
> > >> > is read/write
> > >> > only for the user/group that runs tomcat
> > >> > 2. Make sure apache is on ...
> > >> > 3. in your jsp: use
> > >> > e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
> > >> >
> > >> >
> > >> > Wish it helps
> > >> >
> > >> > On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> > >> >> 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 imagePath = path+"../image_dir/"
> > >> >> and use the imagePath to create my images, then in my jsp
> > >> something like
> > >> >> <request.getContextPath()/../image_dir/image1.jpg>
> > >> >>
> > >> >> But I am not sure this approach works in all configurations,
> > >> >> particularly if my webapp is deployed inside a war.
> > >> >>
> > >> >> Thanks
> > >> >> Romain
> > >> >>
> > >> >> Li wrote:
> > >> >> > 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 <r....@chem.usyd.edu.au> wrote:
> > >> >> >> 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
> tmp
> > >> >> >> directory, unfortunately this directory is not accessible with
> > >> a URL.
> > >> >> >>
> > >> >> >> - Another solution would be to write these images under my
> webapp
> > >> >> >> root(or in another place under my webapp). But it seems that
> this
> > >> >> >> approach does not work with webapps deployed in a war file.
> > >> >> >> Indeed you cannot write inside wars like this.
> > >> >> >>
> > >> >> >> I don't want to rely on some hardcoded solutions. There is
> > >> still the
> > >> >> >> possibility to pass the absolute path to the directory (let's
> say
> > >> >> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
> > >> >> >> <request.getContextPath()/../myimages/image1.jpg>, but I think
> > >> this
> > >> >> >> solution won't work in many configurations
> > >> >> >>
> > >> >> >> Thanks a lot for your help
> > >> >> >> Regards
> > >> >> >> Romain
> > >> >> >>
> > >> >> >>
> > >> >> >>
> > >> >> >>
> > >> >> >>
> > >> ---------------------------------------------------------------------
> > >> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> > >> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > >> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> > >> >> >>
> > >> >> >>
> > >> >> >
> > >> >> >
> > >> >>
> > >> >>
> > >> >>
> > >> >> ------------------------------------------------------------------
> ---
> > >> >> To start a new topic, e-mail: users@tomcat.apache.org
> > >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> > >> >>
> > >> >>
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To start a new topic, e-mail: users@tomcat.apache.org
> > >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > >> For additional commands, e-mail: users-help@tomcat.apache.org
> > >>
> > >>
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Mohsen Saboorian <mo...@gmail.com>.
You can use a servlet init param inside web.xml for avoiding hardcoded
solutions.
e.g.
<context-param>
<param-name>MY_PATH</param-name>
<param-value>c:\my\path\to\imgs</param-value>
</context-param>
On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> 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 pushlets technology).
> The Servlet can only push a String (Pushlets requirements).
>
> So my problem is where can I write the images, so they can be accessible
> by a URL. One easy solution, the one I use for testing, is to hardcode
> in my webapp the directory where the images are written.
> For instance TOMCAT_HOME\webapps\frames\,
> and in my jsp to have <img src="http://myserver/frames/name.jpg> where
> name.jpg is pushed by the servlet when this image is generated.
>
> However, this solution is not satisfactory, indeed, if I deploy my
> application in another place, I don't want people to edit my code to
> change for suitable values. I admit I could use properties or a
> configuration file to set these value(even if I am not sure it would
> work in all configuration), anyway I would like to check if using the
> servletcontext, or other solutions might be more appropriate.
> As I said a solution with the temp directory would be perfect, if this
> directory was accessible with a URL
>
> Hope it is clear
> Regards
> Li wrote:
> > 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 <r....@chem.usyd.edu.au> wrote:
> >> 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. That
> >> is why I am looking for an approach using
> >> the webapp context, so I don't have to worry about the OS, or the port,
> >> or whatever configuration.
> >> Anyway thanks for your help
> >> Regards
> >> Romain
> >>
> >> Li wrote:
> >> > 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
> >> > $APACHE_HOME\httpdocs\images\1.jpg"
> >> > (assume, you had defined APACHE_HOME, make sure the images folder
> >> > is read/write
> >> > only for the user/group that runs tomcat
> >> > 2. Make sure apache is on ...
> >> > 3. in your jsp: use
> >> > e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
> >> >
> >> >
> >> > Wish it helps
> >> >
> >> > On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> >> >> 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 imagePath = path+"../image_dir/"
> >> >> and use the imagePath to create my images, then in my jsp
> >> something like
> >> >> <request.getContextPath()/../image_dir/image1.jpg>
> >> >>
> >> >> But I am not sure this approach works in all configurations,
> >> >> particularly if my webapp is deployed inside a war.
> >> >>
> >> >> Thanks
> >> >> Romain
> >> >>
> >> >> Li wrote:
> >> >> > 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 <r....@chem.usyd.edu.au> wrote:
> >> >> >> 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 tmp
> >> >> >> directory, unfortunately this directory is not accessible with
> >> a URL.
> >> >> >>
> >> >> >> - Another solution would be to write these images under my webapp
> >> >> >> root(or in another place under my webapp). But it seems that this
> >> >> >> approach does not work with webapps deployed in a war file.
> >> >> >> Indeed you cannot write inside wars like this.
> >> >> >>
> >> >> >> I don't want to rely on some hardcoded solutions. There is
> >> still the
> >> >> >> possibility to pass the absolute path to the directory (let's say
> >> >> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
> >> >> >> <request.getContextPath()/../myimages/image1.jpg>, but I think
> >> this
> >> >> >> solution won't work in many configurations
> >> >> >>
> >> >> >> Thanks a lot for your help
> >> >> >> Regards
> >> >> >> Romain
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Romain Quilici <r....@chem.usyd.edu.au>.
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 pushlets technology).
The Servlet can only push a String (Pushlets requirements).
So my problem is where can I write the images, so they can be accessible
by a URL. One easy solution, the one I use for testing, is to hardcode
in my webapp the directory where the images are written.
For instance TOMCAT_HOME\webapps\frames\,
and in my jsp to have <img src="http://myserver/frames/name.jpg> where
name.jpg is pushed by the servlet when this image is generated.
However, this solution is not satisfactory, indeed, if I deploy my
application in another place, I don't want people to edit my code to
change for suitable values. I admit I could use properties or a
configuration file to set these value(even if I am not sure it would
work in all configuration), anyway I would like to check if using the
servletcontext, or other solutions might be more appropriate.
As I said a solution with the temp directory would be perfect, if this
directory was accessible with a URL
Hope it is clear
Regards
Li wrote:
> 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 <r....@chem.usyd.edu.au> wrote:
>> 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. That
>> is why I am looking for an approach using
>> the webapp context, so I don't have to worry about the OS, or the port,
>> or whatever configuration.
>> Anyway thanks for your help
>> Regards
>> Romain
>>
>> Li wrote:
>> > 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
>> > $APACHE_HOME\httpdocs\images\1.jpg"
>> > (assume, you had defined APACHE_HOME, make sure the images folder
>> > is read/write
>> > only for the user/group that runs tomcat
>> > 2. Make sure apache is on ...
>> > 3. in your jsp: use
>> > e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
>> >
>> >
>> > Wish it helps
>> >
>> > On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
>> >> 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 imagePath = path+"../image_dir/"
>> >> and use the imagePath to create my images, then in my jsp
>> something like
>> >> <request.getContextPath()/../image_dir/image1.jpg>
>> >>
>> >> But I am not sure this approach works in all configurations,
>> >> particularly if my webapp is deployed inside a war.
>> >>
>> >> Thanks
>> >> Romain
>> >>
>> >> Li wrote:
>> >> > 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 <r....@chem.usyd.edu.au> wrote:
>> >> >> 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 tmp
>> >> >> directory, unfortunately this directory is not accessible with
>> a URL.
>> >> >>
>> >> >> - Another solution would be to write these images under my webapp
>> >> >> root(or in another place under my webapp). But it seems that this
>> >> >> approach does not work with webapps deployed in a war file.
>> >> >> Indeed you cannot write inside wars like this.
>> >> >>
>> >> >> I don't want to rely on some hardcoded solutions. There is
>> still the
>> >> >> possibility to pass the absolute path to the directory (let's say
>> >> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
>> >> >> <request.getContextPath()/../myimages/image1.jpg>, but I think
>> this
>> >> >> solution won't work in many configurations
>> >> >>
>> >> >> Thanks a lot for your help
>> >> >> Regards
>> >> >> Romain
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To start a new topic, e-mail: users@tomcat.apache.org
>> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To start a new topic, e-mail: users@tomcat.apache.org
>> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> >> For additional commands, e-mail: users-help@tomcat.apache.org
>> >>
>> >>
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Li <am...@gmail.com>.
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 <r....@chem.usyd.edu.au> wrote:
> 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. That
> is why I am looking for an approach using
> the webapp context, so I don't have to worry about the OS, or the port,
> or whatever configuration.
> Anyway thanks for your help
> Regards
> Romain
>
> Li wrote:
> > 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
> > $APACHE_HOME\httpdocs\images\1.jpg"
> > (assume, you had defined APACHE_HOME, make sure the images folder
> > is read/write
> > only for the user/group that runs tomcat
> > 2. Make sure apache is on ...
> > 3. in your jsp: use
> > e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
> >
> >
> > Wish it helps
> >
> > On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> >> 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 imagePath = path+"../image_dir/"
> >> and use the imagePath to create my images, then in my jsp something like
> >> <request.getContextPath()/../image_dir/image1.jpg>
> >>
> >> But I am not sure this approach works in all configurations,
> >> particularly if my webapp is deployed inside a war.
> >>
> >> Thanks
> >> Romain
> >>
> >> Li wrote:
> >> > 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 <r....@chem.usyd.edu.au> wrote:
> >> >> 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 tmp
> >> >> directory, unfortunately this directory is not accessible with a URL.
> >> >>
> >> >> - Another solution would be to write these images under my webapp
> >> >> root(or in another place under my webapp). But it seems that this
> >> >> approach does not work with webapps deployed in a war file.
> >> >> Indeed you cannot write inside wars like this.
> >> >>
> >> >> I don't want to rely on some hardcoded solutions. There is still the
> >> >> possibility to pass the absolute path to the directory (let's say
> >> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
> >> >> <request.getContextPath()/../myimages/image1.jpg>, but I think this
> >> >> solution won't work in many configurations
> >> >>
> >> >> Thanks a lot for your help
> >> >> Regards
> >> >> Romain
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
When we invent time, we invent death.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Romain Quilici <r....@chem.usyd.edu.au>.
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. That
is why I am looking for an approach using
the webapp context, so I don't have to worry about the OS, or the port,
or whatever configuration.
Anyway thanks for your help
Regards
Romain
Li wrote:
> 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
> $APACHE_HOME\httpdocs\images\1.jpg"
> (assume, you had defined APACHE_HOME, make sure the images folder
> is read/write
> only for the user/group that runs tomcat
> 2. Make sure apache is on ...
> 3. in your jsp: use
> e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
>
>
> Wish it helps
>
> On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
>> 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 imagePath = path+"../image_dir/"
>> and use the imagePath to create my images, then in my jsp something like
>> <request.getContextPath()/../image_dir/image1.jpg>
>>
>> But I am not sure this approach works in all configurations,
>> particularly if my webapp is deployed inside a war.
>>
>> Thanks
>> Romain
>>
>> Li wrote:
>> > 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 <r....@chem.usyd.edu.au> wrote:
>> >> 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 tmp
>> >> directory, unfortunately this directory is not accessible with a URL.
>> >>
>> >> - Another solution would be to write these images under my webapp
>> >> root(or in another place under my webapp). But it seems that this
>> >> approach does not work with webapps deployed in a war file.
>> >> Indeed you cannot write inside wars like this.
>> >>
>> >> I don't want to rely on some hardcoded solutions. There is still the
>> >> possibility to pass the absolute path to the directory (let's say
>> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
>> >> <request.getContextPath()/../myimages/image1.jpg>, but I think this
>> >> solution won't work in many configurations
>> >>
>> >> Thanks a lot for your help
>> >> Regards
>> >> Romain
>> >>
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To start a new topic, e-mail: users@tomcat.apache.org
>> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> >> For additional commands, e-mail: users-help@tomcat.apache.org
>> >>
>> >>
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Li <am...@gmail.com>.
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 $APACHE_HOME\httpdocs\images\1.jpg"
(assume, you had defined APACHE_HOME, make sure the images folder
is read/write
only for the user/group that runs tomcat
2. Make sure apache is on ...
3. in your jsp: use
e.g. <a href="http://yourdomain/images/1.jpg">click to view</a>
Wish it helps
On 8/7/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> 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 imagePath = path+"../image_dir/"
> and use the imagePath to create my images, then in my jsp something like
> <request.getContextPath()/../image_dir/image1.jpg>
>
> But I am not sure this approach works in all configurations,
> particularly if my webapp is deployed inside a war.
>
> Thanks
> Romain
>
> Li wrote:
> > 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 <r....@chem.usyd.edu.au> wrote:
> >> 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 tmp
> >> directory, unfortunately this directory is not accessible with a URL.
> >>
> >> - Another solution would be to write these images under my webapp
> >> root(or in another place under my webapp). But it seems that this
> >> approach does not work with webapps deployed in a war file.
> >> Indeed you cannot write inside wars like this.
> >>
> >> I don't want to rely on some hardcoded solutions. There is still the
> >> possibility to pass the absolute path to the directory (let's say
> >> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
> >> <request.getContextPath()/../myimages/image1.jpg>, but I think this
> >> solution won't work in many configurations
> >>
> >> Thanks a lot for your help
> >> Regards
> >> Romain
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
When we invent time, we invent death.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Romain Quilici <r....@chem.usyd.edu.au>.
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 imagePath = path+"../image_dir/"
and use the imagePath to create my images, then in my jsp something like
<request.getContextPath()/../image_dir/image1.jpg>
But I am not sure this approach works in all configurations,
particularly if my webapp is deployed inside a war.
Thanks
Romain
Li wrote:
> 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 <r....@chem.usyd.edu.au> wrote:
>> 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 tmp
>> directory, unfortunately this directory is not accessible with a URL.
>>
>> - Another solution would be to write these images under my webapp
>> root(or in another place under my webapp). But it seems that this
>> approach does not work with webapps deployed in a war file.
>> Indeed you cannot write inside wars like this.
>>
>> I don't want to rely on some hardcoded solutions. There is still the
>> possibility to pass the absolute path to the directory (let's say
>> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
>> <request.getContextPath()/../myimages/image1.jpg>, but I think this
>> solution won't work in many configurations
>>
>> Thanks a lot for your help
>> Regards
>> Romain
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Writing files accessible from a browser
Posted by Li <am...@gmail.com>.
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 <r....@chem.usyd.edu.au> wrote:
> 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 tmp
> directory, unfortunately this directory is not accessible with a URL.
>
> - Another solution would be to write these images under my webapp
> root(or in another place under my webapp). But it seems that this
> approach does not work with webapps deployed in a war file.
> Indeed you cannot write inside wars like this.
>
> I don't want to rely on some hardcoded solutions. There is still the
> possibility to pass the absolute path to the directory (let's say
> TOMCAT_HOME/webapps/myimages/) and later, use inside my JSP
> <request.getContextPath()/../myimages/image1.jpg>, but I think this
> solution won't work in many configurations
>
> Thanks a lot for your help
> Regards
> Romain
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
When we invent time, we invent death.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org