It really depends on how the actual images are acquired and what they are used for.
If you create a site for sharing photos, for example, where the images are first-class citizens, I completely agree with duffymo's answer - they should be loaded with a service layer and be part of the model.
If, on the other hand, the images in question are purely presentation in nature and are available as public images in your web application (for example, you can display the status of a process as red / yellow / green light), you can display them directly in the field of view. Of course, in this scenario, itβs rather strange to store the actual image paths in the database - I would prefer the image path to be stored somewhere in the resource set.
Using the latter approach, presumably the image paths that you have with respect to some "base" folder and the full path to the image will look like ${prefix}/${base}/${imagePath} :
prefix , depending on the deployment configuration, can be explicitly specified somewhere in the configuration (for example, if you have a dedicated image server) OR be as simple as /context , where context is the path where your webapp is deployed (if everything is served from one simple server, without load balancing, etc.)base will be taken from the configuration (or may be empty)imagePath is what you get from the model.
Rendering the image path directly through the JSP should be trivial using the approach described above.
source share