Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 73810 invoked from network); 7 Aug 2006 11:27:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Aug 2006 11:27:15 -0000 Received: (qmail 7750 invoked by uid 500); 7 Aug 2006 11:27:01 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 7729 invoked by uid 500); 7 Aug 2006 11:27:01 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 7718 invoked by uid 99); 7 Aug 2006 11:27:01 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2006 04:27:01 -0700 X-ASF-Spam-Status: No, hits=2.8 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [206.190.53.34] (HELO smtp109.plus.mail.re2.yahoo.com) (206.190.53.34) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 07 Aug 2006 04:27:00 -0700 Received: (qmail 64300 invoked from network); 7 Aug 2006 11:26:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:In-Reply-To:X-MimeOLE:Thread-Index; b=ZpEkWZilQ6IwlQ6yoZeeZVeHftFRnRjx840MHA7NGV6Q5byzY2YSMaeW+93L0ryFQMgp5c2SQk/jKpw4nqeuj3unVw22OBogO6KkXlkN6eAThGLBW+HFw0hN7lGG5C1IiiPpHcQDxqXVtoZXdNRG9CpoE/TNnC801FEF0IlzN74= ; Received: from unknown (HELO timlap) (timlucia@24.62.239.192 with login) by smtp109.plus.mail.re2.yahoo.com with SMTP; 7 Aug 2006 11:26:38 -0000 From: "Tim Lucia" To: "'Tomcat Users List'" Subject: RE: Writing files accessible from a browser Date: Mon, 7 Aug 2006 07:26:36 -0400 Message-ID: <0a1801c6ba14$5817e0f0$0300a8c0@timlap> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <2251114e0608070232p634c851frc473acbb25d43e77@mail.gmail.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: Aca6BOa2Q/51dyuvR4WfYCi/AY6TCwADzkvg X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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. > > MY_PATH > c:\my\path\to\imgs > > > > On 8/7/06, Romain Quilici 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 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. click to view > > >> > > > >> > > > >> > Wish it helps > > >> > > > >> > On 8/7/06, Romain Quilici 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 > > >> >> > > >> >> > > >> >> 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:////image_name.suffix to view. > > >> >> > > > >> >> > On 8/7/06, Romain Quilici 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 > > >> >> >> , 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