I prefer storing in the database because I do not have to code against the file system, operations are handled with transactions, and most of my binary content is generated and related to a specific entity in the system.
This is one of those classic questions. There is not one right answer to this. Intuitively, it would seem like using a JDBC + JBoss to serve multimedia is slower than using plain old file system + Apache, so if you have a high load of stuff to serve, you would want FS + Apache.
However... if the load really is that high, you'll want to be using a caching system on the front-end, so maybe at that point there is no speed advantage of using FS + Apache, because 99% of the hits will come out of the caching system.
On top of this, there is the administration complexity of one vs. the other. It is nice to have a bunch of media content in directories that you can look at, but in some ways it's even nicer to have all your media in a database that you can deal with with replication, DB backup tools, transactions, and all that stuff.
I guess this is an optimization question and one of the facts of optimization is, don't do it until you can prove that you need to, and when that happens, make sure you understand exactly what the performance constraints are.
I think that storing them in a web-accessible folder is very common. I'm not sure why that makes deployment
very difficult- can you elaborate?
One factor that makes it
very difficultis that an EAR deployment doesn't have write-access to any of its own directories so there isn't even a clear way to do it in a normal deployment. Therefore the images need to be somewhere else, this all needs to be coordinated and configured, the image files and the DB entries related to them must be kept in sync, etc. It sure does make deployment into a pain.