My 2 cents:
1) I always try to serve my images from another server (Apache Web Server) configured to serve all the static content, and only send requests to my app server that actually require the app server. As a side effect, paths are easier to manage as they don't change when your application context path changes.
2) If I do serve images from my app server, I definitely don't want my controller servlet processing those requests, as there is no need for logic.
I agree with Erik -- don't tie up your app server with handling image requests. We send all requests to Apache first (whether for static content or for app server content), and then we use mod_jk to proxy app server requests over to JBoss. However, we store all the images on the web server in a path which "looks like" the app server's context path. We like this primarily because it makes it very straightforward for a developer to run the app locally, where we let Tomcat actually serve image requests as well as app server requests. When the developer runs locally, he or she uses a maven command (custom goal) which integrates the static web content into the webapp, while when we build the app for deployment, those assets are left out.
Therefore, we use <html:img> because we want it to manage the context-path prepending for us. Note that <html:img> should always be prepending the context path; if you don't want that behavior, don't use it.
Note, then, that our web server administrator must do two things:
(1) only route app server requests to the app server, which means he can't simply configure everything under "/contextPath" to be sent to the app server -- he usually just uses "/contextPath/*.do" which also discourages developers from exposing JSPs directly, which we consider bad practice.
(2) use an Apache mod_rewrite rule to strip the "jsessionid" from URL requests for images, stylesheets, and other content which we put under the context path -- the URL rewriting which <html:img> does results in that value occasionally being appended, which if left alone, results in a 404 response from the webserver, which doesn't know how to strip it off.
I'm not sure I'd call this "best practice" -- but it is working fine for us.
Joe
Erik
Scott Purcell wrote:
Hello,
As I am building a new (frist time) struts app. I am looking for some insight as to the best way to handle jsp page images.
To make a long story short, my folder structure is this: /dealer /dealer/images /dealer/WEB-INF /dealer/etc.
So all my <img src="/images/etc."> were like this. But because of some IPlanet configuration, my admin, told me we have to change our folder structure so not it is like this:
/dealer/webapp
/dealer/webapp/images
/dealer/webapp/WEB-INF
/dealer/webapp/etc.
But for some reason the dns is looking at /dealer/webapp as one entity. And I would have to put the /dealer/images in front of all paths. This is ok, but when I use the html:img tags, some tags seem to use the context and I can use /images again. But others do not.
I figured this group has probably built quite a few struts apps, and I am looking for some "best practice" ideas, because this app will be deployed many times and I do not want to change links later on in the pages.
Thanks, Scott
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Narrow minds are weapons made for mass destruction" -The Ex
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]