Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-24 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kiran,

On 9/23/12 12:10 AM, Kiran Badi wrote:
 On 9/17/2012 10:20 PM, Christopher Schultz wrote:
 If you instead implemented your own aliases feature using a
 servlet, you could do it in a smarter way because you understand
 your own URL space: you might always know that /images/X will
 translate directly into /file/place/on/the/disk/X and you don't
 have to do a prefix match. You could do something like this:
 
 // configured once MapString,File dirMapping = ...; String
 imageURIPrefix = /images/;
 
 // For each request: String uri = request.getRequestURI(); String
 imageDirStr = uri.substring(0, uri.indexOf('/')); File dir =
 dirMapping.get(imageDirStr);
 
 Now you know where your file should be, and there wasn't any
 linear lookup: it was all done using hashes.
 
 Ah, I can implement it, if my understanding is correct, what you
 are suggesting here is that grab the incoming url, check if they
 are making a request to Images, if yes then point the url to the
 appropriate directory of images for serving.I can do this if it
 gives me good performance.
 
 I was under impression that Tomcat checks for the alias only once
 during it start up phase and somehow maintains the list of it in
 memory and will do automatic match without scanning each alias.My
 bad.

Tomcat must perform the scan for every request.

 Alias as per my understanding is the one of the places where
 Tomcat looks for resources to serve for the requests.

Correct. It's just that the specification is such that it can't be
that smart about finding resources without taking a snapshot of the
whole view of the filesystem and caching it in memory (which itself
isn't very smart).

 Probably not: the suggestion was to use, say, ${imagePrefix} in
 your context's aliases setup to simplify the re-location of your
 image root on disk.
 
 I did not get this probably one of the reasons could be I am still 
 struggling to come to speed.I might need some more days to think as
 what this means in terms of implementation.

Uh, okay.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBgr20ACgkQ9CaO5/Lv0PDsvQCeMKpibaNMc88y0reTbgTGuGcV
RtEAoMGSc0zZgt+Br6ZPFqbFewPcUSA0
=uLtc
-END PGP SIGNATURE-

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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-22 Thread Kiran Badi

On 9/17/2012 10:20 PM, Christopher Schultz wrote:

If you instead implemented your own aliases feature using a servlet,
you could do it in a smarter way because you understand your own URL
space: you might always know that /images/X will translate directly
into /file/place/on/the/disk/X and you don't have to do a prefix
match. You could do something like this:

// configured once
MapString,File dirMapping = ...;
String imageURIPrefix = /images/;

// For each request:
String uri = request.getRequestURI();
String imageDirStr = uri.substring(0, uri.indexOf('/'));
File dir = dirMapping.get(imageDirStr);

Now you know where your file should be, and there wasn't any linear
lookup: it was all done using hashes.


Ah, I can implement it, if my understanding is correct, what you are 
suggesting here is that grab the incoming url, check if they are making 
a request to Images, if yes then point the url to the appropriate 
directory of images for serving.I can do this if it gives me good 
performance.


I was under impression that Tomcat checks for the alias only once during 
it start up phase and somehow maintains the list of it in memory and 
will do automatic match without scanning each alias.My bad.


Alias as per my understanding is the one of the places where Tomcat 
looks for resources to  serve for the requests.


   Probably not: the suggestion was to use, say, ${imagePrefix} in your
   context's aliases setup to simplify the re-location of your image root
   on disk.

I did not get this probably one of the reasons could be I am still 
struggling to come to speed.I might need some more days to think as what 
this means in terms of implementation.


   There's really only one rule for servlet programming:

   Don't use class-level data that changes.

   There are other considerations, of course, but a servlet is not a
   sacred beast. There's only one way to learn how to do it properly:
   fall on your face a few times.

Yes I understand this somewhat and thats the reason probably I am 
somewhat hesitating to reuse some of classes and thats increasing size 
of my code and probably duplicating my code.But again there are some 
good things, I can extend those classes in future and can bring down 
those modules if required without impacting any thing or making an 
changes to existing code.This is only plus point I can see 
now.Everything now is independent of each other. Finally at least I am 
enjoying doing something good rather than finding silly bugs and chasing 
developers for fixing those.


I will upgrade to 7.30 shortly if it saves me some memory.

Thanks Chris and Konstantin.Appreciate your guidance.




Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-17 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kiran,

On 9/13/12 8:24 PM, Kiran Badi wrote:
 On 9/13/2012 8:13 AM, Christopher Schultz wrote:
 Large sites will use a single URL that ends up resolving the
 images from some kind of data source. That data source might be a
 disk (e.g. you could forward to the DefaultServlet) or a database
 (relational or otherwise) where you would write your own servlet
 to retrieve the data yourself.
 
 I would use a servlet that gets the image identifier from the
 request parameters or path info and then continues from there.
 As Konstantin points out, using Tomcat's aliases feature means
 that these requests may have to perform a linear search through
 all the aliases to find the requested resource. If you write a
 custom servlet, it will likely perform much better than that.
 
 this is what I am doing it right now and maybe bit different from
 what large sites do.I can see the point and can write filter which
 will scan the request url and point it to respective images
 directory and then serve it.
 
 I store the images in the respective directory, for example for
 category A with subcategory sc, I store in C://A/sc and then write
 images names to the database.
 
 and via jsp
 
 I get this in this format,
 
 img src =A/test/{Imagename} with image name coming from the
 database.
 
 Below is way it looks in requests.
 
 URLMethodResultTypeReceivedTakenInitiator 
 Wait‎‎Start‎‎Request‎‎Response‎‎Cache read‎‎ Gap‎‎ 
 /our/UploadedImages/sc/cl1.jpgGET200image/jpeg
 40.73 KB0.54 simg21904051410967 
 /our/UploadedImages/sc/cl2.jpgGET200image/jpeg
 45.33 KB327 msimg21902497801186 
 /our/UploadedImages/sc/cl3.jpgGET200image/jpeg
 26.39 KB405 msimg219014026501108 
 /our/UploadedImages/sc/cl4.jpgGET200image/jpeg
 40.73 KB0.51 simg21902812340998 
 /our/UploadedImages/sc/cl5.jpgGET200image/jpeg
 23.43 KB0.51 simg21904051100
 
 However I am not getting if I am writing the single servlet which 
 resolves the images uri, how will it help in improving performance
 ? If Images are in different directories, isn't tomcat needs to
 scan that directory and resolve it?

I'll explain below.

 Initially I had a single directory,but though it would be nightmare
 in case of maintenance, so thought of refactoring it now.
 
 3. Having 200 aliases means that Tomcat would have to try 200 
 different prefixes for each resource lookup. Maybe it would not
 be noticeable (compared to the other time spent in delivering a 
 response), but it still seems like a waste of time.
 
 Why should it do resource lookup when I am telling it to look at
 the exact directory by giving it the exact name of the file ? In
 fact while storing also I am giving it the exact directory path to
 where it needs to store ?

Tomcat keeps a list of aliases that you configure. I haven't looked at
the lookup algorithm but a reasonable implementation would be to store
all the aliases in a big unsorted list and scan them linearly each
time. If you configure 200 aliases, Tomcat will have to scan, on
average, 50% of them to find the alias being used if a match is going
to be found (it's worse when you know a match won't be found, because
Tomcat has to scan all 200 aliases and not find a match). Since
aliases are applied to all URLs, that means that even requests for
non-images will require Tomcat to scan this list. (I'm not sure how
the precedence works with url-mapped servlets, etc... it's possible
that Tomcat will route requests to servlets that have a mapping that
that aliases will not come into play).

By scan I really mean prefix-match: you have to take the incoming
URL and see if *any* of the aliases match. There is no good way to
optimize that operation because it's a prefix match of paths.

If you instead implemented your own aliases feature using a servlet,
you could do it in a smarter way because you understand your own URL
space: you might always know that /images/X will translate directly
into /file/place/on/the/disk/X and you don't have to do a prefix
match. You could do something like this:

// configured once
MapString,File dirMapping = ...;
String imageURIPrefix = /images/;

// For each request:
String uri = request.getRequestURI();
String imageDirStr = uri.substring(0, uri.indexOf('/'));
File dir = dirMapping.get(imageDirStr);

Now you know where your file should be, and there wasn't any linear
lookup: it was all done using hashes.

 Do you believe my understanding the way aliases works is incorrect
 ?

I'm not sure what your understanding of aliases is.

 [Konstantin Kolonko said:] 2. It is possible to define a system
 property (via -D in the options list at startup, or via
 catalina.properties file) and reference it as ${propname}.
 
 This approach will require me to 

Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-13 Thread Vishwanath Washimkar
Chris
I like your approach.

Thanks all I learned the tomcat context concept from your guys...need to
look into it.
Vishwanath

On Thu, Sep 13, 2012 at 8:13 AM, Christopher Schultz 
ch...@christopherschultz.net wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Kiran,

 On 9/11/12 10:44 PM, Kiran Badi wrote:
  On 9/8/2012 4:09 PM, Konstantin Kolinko wrote:
  Regarding the aliases feature:
 
  single path - multiple file paths: No multiple different
  non-intersecting paths - multiple file paths: Yes
 
  As far as I remember, an example of using multiple aliases is
  present in documentation.
  Thanks Konstantin, it seems to be working perfectly fine.
 
  This is how I am doing it now,
 
  Context
 
 aliases=/UploadedImages=c:/UploadedImages,/st=c:/st,/sb=c:/sb,/UploadedImages/scr=c:/UploadedImages/scr,/UploadedImages/scyr=c:/UploadedImages/scyr,/UploadedImages/sem=c:/UploadedImages/sem
 
 
 
  Now I have one clarification, I am going need  close to 150
  categories(think of marketplace) and there will be fair amount of
  images upload which my users will be doing.
 
  I expect the aliases to grow till 150 to 200 paths, do you feel
  this is correct.I am not sure as how large sites deal when they
  have heavy volumes of images getting uploaded on daily basis.

 Large sites will use a single URL that ends up resolving the images
 from some kind of data source. That data source might be a disk (e.g.
 you could forward to the DefaultServlet) or a database (relational or
 otherwise) where you would write your own servlet to retrieve the data
 yourself.

 I would use a servlet that gets the image identifier from the request
 parameters or path info and then continues from there. As Konstantin
 points out, using Tomcat's aliases feature means that these requests
 may have to perform a linear search through all the aliases to find
 the requested resource. If you write a custom servlet, it will likely
 perform much better than that.

 Hope that helps,
 - -chris
 -BEGIN PGP SIGNATURE-
 Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
 Comment: GPGTools - http://gpgtools.org
 Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

 iEYEARECAAYFAlBRSGUACgkQ9CaO5/Lv0PAIbACfYgbM2eyv5TD8uYC7GfV2taUB
 uOAAn1RHpGwal9jkMe6HRiBazEAJ6CCa
 =jqvA
 -END PGP SIGNATURE-

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




Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-13 Thread Kiran Badi

On 9/13/2012 8:13 AM, Christopher Schultz wrote:

Large sites will use a single URL that ends up resolving the images
from some kind of data source. That data source might be a disk (e.g.
you could forward to the DefaultServlet) or a database (relational or
otherwise) where you would write your own servlet to retrieve the data
yourself.

I would use a servlet that gets the image identifier from the request
parameters or path info and then continues from there. As Konstantin
points out, using Tomcat's aliases feature means that these requests
may have to perform a linear search through all the aliases to find
the requested resource. If you write a custom servlet, it will likely
perform much better than that.
 this is what I am doing it right now and maybe bit different from what 
large sites do.I can see the point and can write filter which will scan 
the request url and point it to respective images directory and then 
serve it.



I store the images in the respective directory, for example for category 
A with subcategory sc, I store in C://A/sc and then write images names 
to the database.


and via jsp

I get this in this format,

img src =A/test/{Imagename} with image name coming from the database.

Below is way it looks in requests.

URLMethodResultTypeReceivedTakenInitiator 
Wait‎‎Start‎‎Request‎‎Response‎‎Cache read‎‎ Gap‎‎
/our/UploadedImages/sc/cl1.jpgGET200image/jpeg40.73 
KB0.54 simg21904051410967
/our/UploadedImages/sc/cl2.jpgGET200image/jpeg45.33 
KB327 msimg21902497801186
/our/UploadedImages/sc/cl3.jpgGET200image/jpeg26.39 
KB405 msimg219014026501108
/our/UploadedImages/sc/cl4.jpgGET200image/jpeg40.73 
KB0.51 simg21902812340998
/our/UploadedImages/sc/cl5.jpgGET200image/jpeg23.43 
KB0.51 simg21904051100


However I am not getting if I am writing the single servlet which 
resolves the images uri, how will it help in improving performance ? If 
Images are in different directories, isn't tomcat needs to scan that 
directory and resolve it ?


Initially I had a single directory,but though it would be nightmare in 
case of maintenance, so thought of refactoring it now.




3. Having 200 aliases means that Tomcat would have to try 200
different prefixes for each resource lookup. Maybe it would not be
noticeable (compared to the other time spent in delivering a
response), but it still seems like a waste of time.

Why should it do resource lookup when I am telling it to look at the exact 
directory by giving it the exact name of the file ? In fact while storing also 
I am
giving it the exact directory path to where it needs to store ?

Do you believe my understanding the way aliases works is incorrect ?



2. It is possible to define a system property (via -D in the options

list at startup, or via catalina.properties file) and reference it as
${propname}.

This approach will require me to refactor my existing code,so I will think of 
using this in my next module.There are couple of things I am planning to get it 
dynamically ,but again somewhat scared if I can ever write thread safe 
servlets/classes which can serve multiple concurrent requests.Currently I have 
close to 50% of code which is reused.But I need to deal with this sooner the 
better else I am going to have war file which will be atleast 40mb in size with 
unmanageable number of jsp/servlets/beans.

Thanks Chris and Konstantio for replies.Currently I am on 7.027/7.011 and maybe 
after some days, I will upgrade to 7.030 or still better have one more TC for 
testing purpose.

- Kiran Badi




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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-12 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kiran,

On 9/11/12 10:44 PM, Kiran Badi wrote:
 On 9/8/2012 4:09 PM, Konstantin Kolinko wrote:
 Regarding the aliases feature:
 
 single path - multiple file paths: No multiple different
 non-intersecting paths - multiple file paths: Yes
 
 As far as I remember, an example of using multiple aliases is
 present in documentation.
 Thanks Konstantin, it seems to be working perfectly fine.
 
 This is how I am doing it now,
 
 Context 
 aliases=/UploadedImages=c:/UploadedImages,/st=c:/st,/sb=c:/sb,/UploadedImages/scr=c:/UploadedImages/scr,/UploadedImages/scyr=c:/UploadedImages/scyr,/UploadedImages/sem=c:/UploadedImages/sem

 
 
 Now I have one clarification, I am going need  close to 150 
 categories(think of marketplace) and there will be fair amount of
 images upload which my users will be doing.
 
 I expect the aliases to grow till 150 to 200 paths, do you feel
 this is correct.I am not sure as how large sites deal when they
 have heavy volumes of images getting uploaded on daily basis.

Large sites will use a single URL that ends up resolving the images
from some kind of data source. That data source might be a disk (e.g.
you could forward to the DefaultServlet) or a database (relational or
otherwise) where you would write your own servlet to retrieve the data
yourself.

I would use a servlet that gets the image identifier from the request
parameters or path info and then continues from there. As Konstantin
points out, using Tomcat's aliases feature means that these requests
may have to perform a linear search through all the aliases to find
the requested resource. If you write a custom servlet, it will likely
perform much better than that.

Hope that helps,
- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBRSGUACgkQ9CaO5/Lv0PAIbACfYgbM2eyv5TD8uYC7GfV2taUB
uOAAn1RHpGwal9jkMe6HRiBazEAJ6CCa
=jqvA
-END PGP SIGNATURE-

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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-11 Thread Kiran Badi

On 9/8/2012 4:09 PM, Konstantin Kolinko wrote:

Regarding the aliases feature:

single path - multiple file paths: No
multiple different non-intersecting paths - multiple file paths: Yes

As far as I remember, an example of using multiple aliases is present
in documentation.

Thanks Konstantin, it seems to be working perfectly fine.

This is how I am doing it now,

Context 
aliases=/UploadedImages=c:/UploadedImages,/st=c:/st,/sb=c:/sb,/UploadedImages/scr=c:/UploadedImages/scr,/UploadedImages/scyr=c:/UploadedImages/scyr,/UploadedImages/sem=c:/UploadedImages/sem


Now I have one clarification, I am going need  close to 150 
categories(think of marketplace) and there will be fair amount of images 
upload which my users will be doing.


I expect the aliases to grow till 150 to 200 paths, do you feel this is 
correct.I am not sure as how large sites deal when they have heavy 
volumes of images getting uploaded on daily basis.


Do I need to cautious here on anything.



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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-11 Thread Konstantin Kolinko
2012/9/12 Kiran Badi ki...@poonam.org:
 On 9/8/2012 4:09 PM, Konstantin Kolinko wrote:

 Regarding the aliases feature:

 single path - multiple file paths: No
 multiple different non-intersecting paths - multiple file paths: Yes

 As far as I remember, an example of using multiple aliases is present
 in documentation.

 Thanks Konstantin, it seems to be working perfectly fine.

 This is how I am doing it now,

 Context
 aliases=/UploadedImages=c:/UploadedImages,/st=c:/st,/sb=c:/sb,/UploadedImages/scr=c:/UploadedImages/scr,/UploadedImages/scyr=c:/UploadedImages/scyr,/UploadedImages/sem=c:/UploadedImages/sem

 Now I have one clarification, I am going need  close to 150 categories(think
 of marketplace) and there will be fair amount of images upload which my
 users will be doing.

 I expect the aliases to grow till 150 to 200 paths, do you feel this is
 correct.I am not sure as how large sites deal when they have heavy volumes
 of images getting uploaded on daily basis.

 Do I need to cautious here on anything.

1. You can add whitespace around ',' and '=' for better readability.
(I do not remember whether 7.0.27 allows it, but 7.0.30 should allow
whitespace there).

2. It is possible to define a system property (via -D in the options
list at startup, or via catalina.properties file) and reference it as
${propname}.

3. Having 200 aliases means that Tomcat would have to try 200
different prefixes for each resource lookup. Maybe it would not be
noticeable (compared to the other time spent in delivering a
response), but it still seems like a waste of time.

Best regards,
Konstantin Kolinko

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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-08 Thread Konstantin Kolinko
2012/9/8 Kiran Badi ki...@poonam.org:
 Hi Chris and All,

 I hope its alright if I reopen my old thread since I want to expand my
 earlier requirement.

 I have a requirement  where for each category I need to have separate
 folders where the Images should go in.

 Currently for all categories my images goes into the C://UploadedImages
 folder and it working fine.

 Context aliases=/UploadedImages=c:/UploadedImages/Context

 Now I was wondering , if its possible that I can do something like,

 Context
 aliases=/UploadedImages=c:/Uploaded/Images/Product1Images,c:/UploadedImages/Product2Images,c:/UploadedImages/Product3Images.c:/UploadedImages/ProductNImages/Context

Regarding the aliases feature:

single path - multiple file paths: No
multiple different non-intersecting paths - multiple file paths: Yes

As far as I remember, an example of using multiple aliases is present
in documentation.

Best regards,
Konstantin Kolinko

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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-08 Thread Kiran Badi

Thanks Konstantin, I will check this and revert back.

On 9/8/2012 4:09 PM, Konstantin Kolinko wrote:

2012/9/8 Kiran Badi ki...@poonam.org:

Hi Chris and All,

I hope its alright if I reopen my old thread since I want to expand my
earlier requirement.

I have a requirement  where for each category I need to have separate
folders where the Images should go in.

Currently for all categories my images goes into the C://UploadedImages
folder and it working fine.

Context aliases=/UploadedImages=c:/UploadedImages/Context

Now I was wondering , if its possible that I can do something like,

Context
aliases=/UploadedImages=c:/Uploaded/Images/Product1Images,c:/UploadedImages/Product2Images,c:/UploadedImages/Product3Images.c:/UploadedImages/ProductNImages/Context

Regarding the aliases feature:

single path - multiple file paths: No
multiple different non-intersecting paths - multiple file paths: Yes

As far as I remember, an example of using multiple aliases is present
in documentation.

Best regards,
Konstantin Kolinko

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





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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-09-07 Thread Kiran Badi

Hi Chris and All,

I hope its alright if I reopen my old thread since I want to expand my 
earlier requirement.


I have a requirement  where for each category I need to have separate 
folders where the Images should go in.


Currently for all categories my images goes into the C://UploadedImages 
folder and it working fine.


Context aliases=/UploadedImages=c:/UploadedImages/Context

Now I was wondering , if its possible that I can do something like,

Context 
aliases=/UploadedImages=c:/Uploaded/Images/Product1Images,c:/UploadedImages/Product2Images,c:/UploadedImages/Product3Images.c:/UploadedImages/ProductNImages/Context

I should be having 100+ products with somewhat similar design in 
nature,I just want to put them in their own folders.


Can I do this with Tomcat 7.027 or latest version.I can upgrade if 
required.I remember sometimes back this was requirement for one of the 
posters here and I believe someone had asked him to file for enhancement 
request.So was wondering if this can be done now.


If this cannot be done with Tomcat, is their any other open source 
solution for this.I can code couple of lines if this saves me some bugs.


On 6/5/2012 7:41 PM, Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kiran,

On 6/5/12 1:31 AM, Kiran Badi wrote:

After playing around for a day,

this is another solutions which worked for me,

Context aliases=/UploadedImages=c:/UploadedImages/Context
with Tomcat 7.0.11 in context.xml

Good, except that you should really upgrade to the latest Tomcat 7.0
version. Plenty of security fixed have been shipped since 7.0.11.


I think now I understand as how aliases work, /UploadedImages is
the aliaspath and c:/UploadedImages is the docbase to which it
refers.

Is this understanding correct ?

/UploadedImages is the URL where resources in C:\UploadedImages can be
requested. The term docbase doesn't really apply as it has a number
of connotations that aren't appropriate here.


In manager app I see something called /files , not sure as what is
this ?

That is likely to be another webapp, but I have no idea where in the
manager app you are looking, so I can't really comment.

Remember that Tomcat will (by default) auto-deploy any directory in
the CATALINA_BASE/webapps directory -- even those that you don't
consider to be a legitimate webapp. So, if you have a directory called
files in there, then Tomcat will deploy that into /files and
possibly expose some resources that you hadn't intended to be
available via HTTP.

- -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/OE5UACgkQ9CaO5/Lv0PDk9gCgizMK2Qv4pjSPt+4zNORyQ59D
PfgAoLWM3pz9K/aPLIvGuwKHQKVmYOxF
=M4dM
-END PGP SIGNATURE-

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





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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-06-05 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kiran,

On 6/5/12 1:31 AM, Kiran Badi wrote:
 After playing around for a day,
 
 this is another solutions which worked for me,
 
 Context aliases=/UploadedImages=c:/UploadedImages/Context
 with Tomcat 7.0.11 in context.xml

Good, except that you should really upgrade to the latest Tomcat 7.0
version. Plenty of security fixed have been shipped since 7.0.11.

 I think now I understand as how aliases work, /UploadedImages is
 the aliaspath and c:/UploadedImages is the docbase to which it
 refers.
 
 Is this understanding correct ?

/UploadedImages is the URL where resources in C:\UploadedImages can be
requested. The term docbase doesn't really apply as it has a number
of connotations that aren't appropriate here.

 In manager app I see something called /files , not sure as what is
 this ?

That is likely to be another webapp, but I have no idea where in the
manager app you are looking, so I can't really comment.

Remember that Tomcat will (by default) auto-deploy any directory in
the CATALINA_BASE/webapps directory -- even those that you don't
consider to be a legitimate webapp. So, if you have a directory called
files in there, then Tomcat will deploy that into /files and
possibly expose some resources that you hadn't intended to be
available via HTTP.

- -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/OE5UACgkQ9CaO5/Lv0PDk9gCgizMK2Qv4pjSPt+4zNORyQ59D
PfgAoLWM3pz9K/aPLIvGuwKHQKVmYOxF
=M4dM
-END PGP SIGNATURE-

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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-06-05 Thread Kiran Badi



On 6/5/2012 7:41 PM, Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kiran,

On 6/5/12 1:31 AM, Kiran Badi wrote:

After playing around for a day,

this is another solutions which worked for me,

Context aliases=/UploadedImages=c:/UploadedImages/Context
with Tomcat 7.0.11 in context.xml

Good, except that you should really upgrade to the latest Tomcat 7.0
version. Plenty of security fixed have been shipped since 7.0.11.


Yes , I will try to give a shot.But it will take sometime.But 
application is deployed in latest tomcat version 7.0.27 and this is my 
development server.

I think now I understand as how aliases work, /UploadedImages is
the aliaspath and c:/UploadedImages is the docbase to which it
refers.

Is this understanding correct ?

/UploadedImages is the URL where resources in C:\UploadedImages can be
requested. The term docbase doesn't really apply as it has a number
of connotations that aren't appropriate here.


Thanks for clarification.



In manager app I see something called /files , not sure as what is
this ?

That is likely to be another webapp, but I have no idea where in the
manager app you are looking, so I can't really comment.

Remember that Tomcat will (by default) auto-deploy any directory in
the CATALINA_BASE/webapps directory -- even those that you don't
consider to be a legitimate webapp. So, if you have a directory called
files in there, then Tomcat will deploy that into /files and
possibly expose some resources that you hadn't intended to be
available via HTTP.
Kiran : Yup, Had an empty files folder inside webapps and this was 
showing up.


Many thanks Chris,Appreciate your assistance.

- -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/OE5UACgkQ9CaO5/Lv0PDk9gCgizMK2Qv4pjSPt+4zNORyQ59D
PfgAoLWM3pz9K/aPLIvGuwKHQKVmYOxF
=M4dM
-END PGP SIGNATURE-

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





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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-06-04 Thread Kiran Badi

After playing around for a day,

this is another solutions which worked for me,

Context aliases=/UploadedImages=c:/UploadedImages/Context with 
Tomcat 7.0.11 in context.xml


I think now I understand as how aliases work, /UploadedImages is the 
aliaspath and c:/UploadedImages is the docbase to which it refers.


Is this understanding correct ?

In manager app I see something called /files , not sure as what is this ?

On 6/2/2012 4:45 AM, Kiran Badi wrote:


On 6/1/2012 9:27 PM, Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kiran,

On 5/31/12 10:37 PM, Kiran Badi wrote:

Ok I did it this way in TC 7.0.27 as I decided not to touch
Netbeans setup with 7.0.11( I had messed up TC7.0.11 after doing
several trial and error stuff,felt real pain)

I have TC7.0.27 running as window service which I use it deploy my
latest build everyday.

In server xml, I added below context between host tags

Context path=/myapp/UploadedImages docBase=c:\UploadedImages
reloadable=true crossContext=true /

You shouldn't putContext  elements in server.xml. Also, using a
docBase that has files appear at random can be problematic when it
comes to caching, etc. and users often have problems.
Kiran : I had never thought about caching , and  caching is one of key 
features which I am planning to implement.

so I did not use aliases at all, is this good solution or I am
missing something again.

Presumably you have an existing webapp that does the upload part: make
C:\UploadedImages into an alias for that webapp instead of creating
a second webapp for it.

Ok I will give try to create alias and see how it goes.

Thanks.


- -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/I5l0ACgkQ9CaO5/Lv0PCtJwCgrGbdhRjeSetyRz8Zr3Bvzkt0
mU0AnidgFANsdy8ZFNoo8/SPLCCY11+E
=7Q6w
-END PGP SIGNATURE-

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







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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-06-01 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kiran,

On 5/31/12 10:37 PM, Kiran Badi wrote:
 Ok I did it this way in TC 7.0.27 as I decided not to touch
 Netbeans setup with 7.0.11( I had messed up TC7.0.11 after doing
 several trial and error stuff,felt real pain)
 
 I have TC7.0.27 running as window service which I use it deploy my 
 latest build everyday.
 
 In server xml, I added below context between host tags
 
 Context path=/myapp/UploadedImages docBase=c:\UploadedImages 
 reloadable=true crossContext=true /

You shouldn't put Context elements in server.xml. Also, using a
docBase that has files appear at random can be problematic when it
comes to caching, etc. and users often have problems.

 so I did not use aliases at all, is this good solution or I am
 missing something again.

Presumably you have an existing webapp that does the upload part: make
C:\UploadedImages into an alias for that webapp instead of creating
a second webapp for it.

- -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/I5l0ACgkQ9CaO5/Lv0PCtJwCgrGbdhRjeSetyRz8Zr3Bvzkt0
mU0AnidgFANsdy8ZFNoo8/SPLCCY11+E
=7Q6w
-END PGP SIGNATURE-

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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-06-01 Thread Kiran Badi


On 6/1/2012 9:27 PM, Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kiran,

On 5/31/12 10:37 PM, Kiran Badi wrote:

Ok I did it this way in TC 7.0.27 as I decided not to touch
Netbeans setup with 7.0.11( I had messed up TC7.0.11 after doing
several trial and error stuff,felt real pain)

I have TC7.0.27 running as window service which I use it deploy my
latest build everyday.

In server xml, I added below context between host tags

Context path=/myapp/UploadedImages docBase=c:\UploadedImages
reloadable=true crossContext=true /

You shouldn't putContext  elements in server.xml. Also, using a
docBase that has files appear at random can be problematic when it
comes to caching, etc. and users often have problems.
Kiran : I had never thought about caching , and  caching is one of key 
features which I am planning to implement.

so I did not use aliases at all, is this good solution or I am
missing something again.

Presumably you have an existing webapp that does the upload part: make
C:\UploadedImages into an alias for that webapp instead of creating
a second webapp for it.

Ok I will give try to create alias and see how it goes.

Thanks.


- -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/I5l0ACgkQ9CaO5/Lv0PCtJwCgrGbdhRjeSetyRz8Zr3Bvzkt0
mU0AnidgFANsdy8ZFNoo8/SPLCCY11+E
=7Q6w
-END PGP SIGNATURE-

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





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



Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-05-31 Thread Kiran Badi
Ok I did it this way in TC 7.0.27 as I decided not to touch Netbeans 
setup with 7.0.11( I had messed up TC7.0.11 after doing several trial 
and error stuff,felt real pain)


I have TC7.0.27 running as window service which I use it deploy my 
latest build everyday.


In server xml, I added below context between host tags

Context path=/myapp/UploadedImages
 docBase=c:\UploadedImages
 reloadable=true
 crossContext=true /

so I did not use aliases at all, is this good solution or I am missing 
something again.


Appreciate some feedback on this one as I really dont want to have 
rework again.

On 5/31/2012 9:33 AM, Kiran Badi wrote:

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 AMDIR   . 03/30/2012  07:40 AMDIR
.. 06/12/2011  05:16 AMDIR   docs 06/12/2011  05:16 AM
DIR   examples 03/30/2012  07:40 AMDIR   files
06/12/2011  05:16 AMDIR   host-manager 06/12/2011  05:16
AMDIR   manager 06/12/2011  05:16 AMDIR   ROOT

If you want to make this server 

Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-05-30 Thread Kiran Badi

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 AMDIR   . 03/30/2012  07:40 AMDIR
.. 06/12/2011  05:16 AMDIR   docs 06/12/2011  05:16 AM
DIR   examples 03/30/2012  07:40 AMDIR   files
06/12/2011  05:16 AMDIR   host-manager 06/12/2011  05:16
AMDIR   manager 06/12/2011  05:16 AMDIR   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-unsubscr...@tomcat.apache.org
For 

Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-05-29 Thread Christopher Schultz
-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



Where do I store Images in tomcat structure so that I can retrive it properly in all browsers

2012-05-28 Thread Kiran Badi

Hi,

I am using Tomcat 7.0.11 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.


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

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


My tomcat 7.0.11 structure looks something like below,


C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.11dir
 Volume in drive C is OS
 Volume Serial Number is 8255-4D52

 Directory of C:\Program Files\Apache Software Foundation\Apache Tomcat 
7.0.11


06/12/2011  05:17 AM DIR  .
06/12/2011  05:17 AM DIR  ..
06/12/2011  05:16 AM DIR  bin
08/16/2011  09:05 AM DIR  conf
12/07/2011  07:25 AM DIR  lib
03/10/2011  03:44 PM57,851 LICENSE
05/29/2012  12:05 AM DIR  logs
03/10/2011  03:44 PM 1,230 NOTICE
03/10/2011  03:44 PM 9,011 RELEASE-NOTES
03/10/2011  03:44 PM 6,860 RUNNING.txt
05/29/2012  03:44 AM DIR  temp
06/12/2011  05:17 AM 2,221,126 uninstall.exe
03/30/2012  07:40 AM DIR  webapps
08/14/2011  08:15 AM DIR  work
   5 File(s)  2,296,078 bytes
   9 Dir(s)  245,526,077,440 bytes free

C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.11cd webapps

C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.11\webappsdir
 Volume in drive C is OS


 Directory of C:\Program Files\Apache Software Foundation\Apache Tomcat 
7.0.11\w

ebapps

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
   0 File(s)  0 bytes
   8 Dir(s)  245,526,077,440 bytes free

C:\Program Files\Apache Software Foundation\Apache Tomcat 
7.0.11\webappscd root



C:\Program Files\Apache Software Foundation\Apache Tomcat 
7.0.11\webapps\ROOTdi

r
 Volume in drive C is OS
 Volume Serial Number is 8255-4D52

 Directory of C:\Program Files\Apache Software Foundation\Apache Tomcat 
7.0.11\w

ebapps\ROOT

06/12/2011  05:16 AM DIR  .
06/12/2011  05:16 AM DIR  ..
03/10/2011  03:44 PM 5,866 asf-logo-wide.gif
03/10/2011  03:44 PM17,811 asf-logo.png
03/10/2011  03:44 PM   713 bg-button.png
03/10/2011  03:44 PM 1,918 bg-middle.png
03/10/2011  03:44 PM 1,392 bg-nav-item.png
03/10/2011  03:44 PM 1,401 bg-nav.png
03/10/2011  03:44 PM 3,103 bg-upper.png
03/10/2011  03:44 PM 3,469 build.xml
03/10/2011  03:44 PM21,630 favicon.ico
03/10/2011  03:44 PM13,066 index.jsp
03/10/2011  03:44 PM 9,011 RELEASE-NOTES.txt
03/10/2011  03:44 PM 2,376 tomcat-power.gif
03/10/2011  03:44 PM 6,074 tomcat.css
03/10/2011  03:44 PM 2,066 tomcat.gif
03/10/2011  03:44 PM 5,103 tomcat.png
03/10/2011  03:44 PM67,792 tomcat.svg
06/12/2011  05:16 AM DIR  WEB-INF
  16 File(s)162,791 bytes
   3 Dir(s)  245,526,085,632 bytes free

C:\Program Files\Apache Software Foundation\Apache Tomcat 
7.0.11\webapps\ROOT






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