-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kiran,
On 5/28/12 6:38 PM, Kiran Badi wrote: > I am using Tomcat 7.0.11 Upgrade. http://tomcat.apache.org/security-7.html > and environment is win 7 home premium with servlet/jsp/jstl with > netbeans 7.01 > > I have form where in I upload the image to the folder C://xx > using apache commons file upload and then store the file name to > the DB.Everything is good till here. Good. > Then when I want to display the same image, I query the database > using servlet and store the image name to attribute like > > request.setAttribute("collegesimg", img); > > now via front end jsp, I want to display the same image stored in > attribute, > > I do > > <img src="C://UploadedImages/${collegesimg}" width="80%" > height="500"> Assuming that C://xx and C://UploadedImages are the same thing, then this will work only if your remote user is actually on your own machine (the server). File paths wont work as URLs unless they are local. > Now this works perfectly fine,but FF/Chrome fails saying cannot > load local resources with 404 status. > > Now I can understand that this is FF/Chrome by default do allow to > access local file system on the client.Good till here. > > But I am not able to figure out where do I store the images now so > that I can display it correctly and they remain in place when I > redeploy the app? First, you need to reference them from your web pages using http:// URLs like this: <img src="http://server/UploadedImages/${collegesimg}" width="80%" height="500"> (Are you sure its appropriate to have images always at 500px and 80% parent-width?) > Is their any place in Tomcat's dir structure where the folder is > still called root folder and when we undeploy or redeploy , images > still remains intact ? If you put your uploaded pictures into your webapp's deployment directory, you are very likely to have them deleted when your webapp is undeployed. So, put them somewhere else. Since you are using Tomcat 7, your best bet is to use the "alias" feature: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Standard_Implementation (Read about the 'aliases' configuration attribute) > My tomcat 7.0.11 structure looks something like below, It doesn't matter, because you need to put your files elsewhere. > Directory of C:\Program Files\Apache Software Foundation\Apache > Tomcat 7.0.11\webapps > > 03/30/2012 07:40 AM <DIR> . 03/30/2012 07:40 AM <DIR> > .. 06/12/2011 05:16 AM <DIR> docs 06/12/2011 05:16 AM > <DIR> examples 03/30/2012 07:40 AM <DIR> files > 06/12/2011 05:16 AM <DIR> host-manager 06/12/2011 05:16 > AM <DIR> manager 06/12/2011 05:16 AM <DIR> ROOT If you want to make this server public, you are going to want to undeploy everything you don't need: do you need the host-manager, etc.? - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk/E4R8ACgkQ9CaO5/Lv0PBbCACgrk43sQypzrEsmEco17DxEY05 kD8AnRowLUYfLYgmJdc+5w3h4lfm2Qku =g4v7 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org