tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Badi <ki...@poonam.org>
Subject Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers
Date Thu, 31 May 2012 04:03:47 GMT
On 5/29/2012 8:15 PM, Christopher Schultz wrote:
> -----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
Yup, I already have 7.0.27 and this one is tied with netbeans and I 
really do not want to disturb this environment.
>
>> 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.
Yes they are same and aware of this information.
>
>> 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">

Yes I am trying this now,but still getting 404 with 
http://localhost:8080/servername/UploadedImages/image.jpeg(Yes image do 
exist in folder)
Here is what I tried after reading  googling and binging
I added this to server.xml,

<Context path="/ourstory"
              docBase="c:\UploadedImages"
              reloadable="true"
              crossContext="true" />
I know something is incorrect here or totally wrong.
>
> (Are you sure its appropriate to have images always at 500px and 80%
> parent-width?)
I am currently experimenting with designs.Again this is not full 
screenwidth, they are sized based on container sizes.I have form 
enclosed withing div.
>> 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)
This aliases feature is really helpful feature.But my bad, I can see the 
importance of this feature,but unfortunately not able to get much info 
on net wrt to Tomcat 7.
I did try to add context element in Meta-inf/Context.xml and server.xml, 
in all the cases build creation failed probably due to malformed context 
xml.
I will try again tommarrow.Seems like I need to understand as how 
Netbeans sets up the context for the project and then accordingly I need 
to proceed.

By any chance

Is their any example for this anywhere on Tomcat site ? .

Also I believe that if I implement this aliases , I might not need to 
write streaming servlet to read images or have httpd infront of tomcat.I 
want to avoid both since I already have many jsp/servlets and httpd ,i 
dont see a reason as my application is dynamic and plain DB 
calls.Nothing really complicated.

>
>> 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.?

No I dont need these ,I will check and remove once I decide to put this 
on live.

Thanks chris for your reply.

>
> - -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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message