the question also meant to ask how the servlet should be written to pass up an image
Main Topics
Browse All TopicsI have an application which uses different base url during preview and runtime mode.
I am setting all the <img src> based on runtime setup. but they all fail during preview. is there a way I can intercept all the image requests using a servlet and serve up the image content with a response write?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I was able to trap the image requests by setting the right url pattern, and the images do show up. but they seem to ignore the width setting.
the html is
'<img id="TopLogo_logo_jpg_id" src="images/logo.jpg" width=120>
is there any reason using the method you provided that the image would ignore the width setting in the html?
there really is a problem.
compared to calling up the image directory (without servlet), the html
'<img id="TopLogo_logo_jpg_id" src="images/logo.jpg" width=120> would allocated a block 1024 wide, but the image stays at original width of 64, and the whole layout looks nice. but using the servlet, the image gets stretched to the full 120 in width and look down right ugly.
I am looking to have the same effect as when images are loaded directly. is there a way to get the servlet to do the same?
I did not follow that part of your suggestion, because I know I can trap the image loading by its url anyhow. doing it this way, I don't interfere with loading of platform related images, only my application specific images.
but the question is unrelated to the src attribute, it is now focusing on the width specification. why is there this differences in response to the width attribute when using the servlet approach. do you know?
obviously you are missing one point i am making. I used the url-patterns like
/images to pick up my image requests for images and redirect those request to my servlet. so even though it looks like a static image request, it is actually a dynamic one.
other static images which does not sit in /images directly still get served up statically. does this clarify what I am doing?
the key question is not how I am triggering the servlet, but the fact that static images do not seem to be stretched according to the width attribute, but the dynamic ones do. is that the behavior you would expect? if possible, I would like them to behave identically.
that is contrary to what I know. for any given image, should't you be able to define either the width or height and have the browser adjust the missing attribute?
The point is for static images, it actually ignore my width setting, and used the natural image width. while use the specified width to set margins around the image. if you are familiar with such behavior, I like to learn about it.
Business Accounts
Answer for Membership
by: CEHJPosted on 2009-05-29 at 23:18:49ID: 24507986
You can get a servlet to handle the images:
<img src="/imageServlet" ......... />
And the servlet would base what it returns on the presence/absence of a form parameter such as previewMode=true