Re: Unable to access files outside Webapp directory in tomcat
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Akash, On 9/2/2009 1:32 AM, asingla4 wrote: I have my Web application installed in C:\Tomcat\webapp\ROOT. Now, through the Web page of this application, the user uploads an image which the application saves in C:\files folder using ImageIO class of JAVA. Aah, the magic of using an image API to save byte streams. You didn't need that extra CPU time for anything, did you? Now as soon as the file is uploaded, there should be a download button enabled for this uploaded image. If the user hits download, he should be able to download the file he uploaded. Okay, so you want to allow remote clients to access uploaded files through a URL pattern. No problem. I'm done with saving the file to C:\files but I don't know how to make it downloadable when the download button is clicked because the files folder is outside the webapp directory. You have a few options: 1. Create a new context called, say, files and point it at c:\files. You can do this by creating CATALINA_BASE/conf/[servicename]/[hostname]/files.xml with this content: Context docBase=C:\files / OR 2. Write a servlet mapped to /files/* (or whatever) that looks-up files in /files and just streams them to the client. #2 would be better if you need to be logged-in to your webapp in order to download files. #1 is more convenient because you don't have to write any code. Hope that helps, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkqgMAEACgkQ9CaO5/Lv0PBHrQCfdqj0/q0jQPpmhevbuqEblM/b rf8An2cq0u6UPUzRs20h/5xLestYqDSw =8D0G -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Unable to access files outside Webapp directory in tomcat
asingla4 schrieb: I'm done with saving the file to C:\files but I don't know how to make it downloadable when the download button is clicked because the files folder is outside the webapp directory. Please read this thread: providing downloading functionality for a file which is on disk http://markmail.org/thread/ixx6oxtkdukp4xtf Especially Chuck's reply: RE: providing downloading [...] - Caldarale, Charles R http://markmail.org/message/6e2vxa3eixd5cvgf -- Michael Ludwig - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Unable to access files outside Webapp directory in tomcat
Hi, Initially, I was accessing the files using the absolute path, but this way I'm unable to download the files through my web Page (the download image on the page would require a relative path as src.) So, eventually, I haven't been able to try anything. Akash Christopher Schultz-2 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Akash, On 8/30/2009 12:34 PM, asingla4 wrote: I have kept all the documents and images outside the root directory of the application. How can I access these files in my application[?] What have you already tried? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEUEARECAAYFAkqb848ACgkQ9CaO5/Lv0PDYKQCVFFj6UJlSTTEFn0qemuv5J3R0 3gCggNJlZP3lGSIgZ+syit2FrKcV/88= =yW0Z -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org -- View this message in context: http://www.nabble.com/Unable-to-access-files-outside-Webapp-directory-in-tomcat-tp25213157p25244051.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Unable to access files outside Webapp directory in tomcat
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Akash, On 9/1/2009 1:36 PM, asingla4 wrote: Initially, I was accessing the files using the absolute path Accessing the files with what? A fork and knife? but this way I'm unable to download the files through my web Page (the download image on the page would require a relative path as src.) Are you trying to read a file off the disk using something like FileInputStream, or are you trying to access a file from the server using a URL from a browser? These are very basic questions whose answers will certainly help solve your problem. So, eventually, I haven't been able to try anything. :( - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkqdYrgACgkQ9CaO5/Lv0PD7WQCfTSxFJk3ZEDTaHcxGvzYBF+Qi eKkAn2KnfKydHyLHxASNw/qx5N4NoZKJ =OmST -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Unable to access files outside Webapp directory in tomcat
Hi, I have my Web application installed in C:\Tomcat\webapp\ROOT. Now, through the Web page of this application, the user uploads an image which the application saves in C:\files folder using ImageIO class of JAVA. Now as soon as the file is uploaded, there should be a download button enabled for this uploaded image. If the user hits download, he should be able to download the file he uploaded. I'm done with saving the file to C:\files but I don't know how to make it downloadable when the download button is clicked because the files folder is outside the webapp directory. I hope this explains my issue. Thanks Akash. Christopher Schultz-2 wrote: Are you trying to read a file off the disk using something like FileInputStream, or are you trying to access a file from the server using a URL from a browser? These are very basic questions whose answers will certainly help solve your problem. -- View this message in context: http://www.nabble.com/Unable-to-access-files-outside-Webapp-directory-in-tomcat-tp25213157p25251880.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Unable to access files outside Webapp directory in tomcat
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Akash, On 8/30/2009 12:34 PM, asingla4 wrote: I have kept all the documents and images outside the root directory of the application. How can I access these files in my application[?] What have you already tried? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEUEARECAAYFAkqb848ACgkQ9CaO5/Lv0PDYKQCVFFj6UJlSTTEFn0qemuv5J3R0 3gCggNJlZP3lGSIgZ+syit2FrKcV/88= =yW0Z -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Unable to access files outside Webapp directory in tomcat
Hi All, I am developing a web application with JDK 1.6 and Tomcat 6.0. I have kept all the documents and images outside the root directory of the application. How can I access these files in my application. Please suggest Thanks Akash Singla TheDaedals.com -- View this message in context: http://www.nabble.com/Unable-to-access-files-outside-Webapp-directory-in-tomcat-tp25213157p25213157.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org