This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes unable to display image files in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "unable to display image files in jsp" Watch "unable to display image files in jsp" New topic
Author

unable to display image files in jsp

Subbu Aswathanarayan
Ranch Hand

Joined: Jun 22, 2001
Posts: 73
Hi all,
my jsp page does not display any image files if i give the relative path for the images.they are displayed only when i give the absolute path.
any idea why this is happening.
i am using JRun 3.1/NT 4.0 /IIS 4.0
my directory structure is something like this.
my application root directory is
c:\project\test
my jsp file is in the above directory.
the images directory is a sub directory of /test
my application mapping is
/login
for eg the following doesn't work
<img border="0" src="images/header.jpg" width="580" height="72">
but this works
<img border="0" src="http://abc.xy.com/login/images/header.jpg" width="580" height="72">
for obvious reasons i want to use the first method.

Any help would be greatly appreciated.
Subbu

Subbu
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

Check your IIS config - the images should be sent by IIS and not JRUN, so your "relative" path is relative to the configuration of the particular server that handles the embedded URL.
Also, please do me a big favor! If you haven't patched IIS to deny the "Code Red" worm, please do so - my servers got hammered all day long yesterday by infected machines.


Customer surveys are for companies who didn't pay proper attention to begin with.
Subbu Aswathanarayan
Ranch Hand

Joined: Jun 22, 2001
Posts: 73
Originally posted by Tim Holloway:
Check your IIS config - the images should be sent by IIS and not JRUN, so your "relative" path is relative to the configuration of the particular server that handles the embedded URL.
Also, please do me a big favor! If you haven't patched IIS to deny the "Code Red" worm, please do so - my servers got hammered all day long yesterday by infected machines.

thanks tim.
it works after i copied my images folder to IIS root directory.
also i have installed the patch u were talking abt.
Thanks a lot.
Subbu
[This message has been edited by Subbu Aswathanarayan (edited July 20, 2001).]
Subbu Aswathanarayan
Ranch Hand

Joined: Jun 22, 2001
Posts: 73
hi,
sorry but i was wrong.i am still not able to display the images in the jsp file.i see a blank screen with a X mark on the top left corner.
when i right clicked on that X mark and saw the properties, i observed that it is searching for the images folder inside /servlet directory.there is no such directory.i am using JRun and in JRun /servlet is mapped to web-inf/classes where i have placed my servlet class files.i am actually forwarding the request from the servlet to the jsp file.
i have tried everything but nothing seems to work.
any help would be greatly appreciated.
Subbu
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

In cases like that, I look at the logfiles to see which server (if any!) tried to resolve the URL and to what file it attempted to resolve it to.
I think that you've found the problem - the path is being set relative to the /servlet virtual directory, and IIS is looking for a /servlet directory and not finding one and/or passing the image URL over to JRun which has its own slant. I'm unclear on the exact process here because it's been a long time since I've worked with JRUN, but makes no difference. I've commonly kept the images in their own virtual directory to simplify housekeeping (you can share images between sites, no intermingling with html files, etc.), so my references would be in the form <img src="/img/myPic.jpg" alt="A picture">. I think this approach will solve your problem - just define a virtual directory on IIS for images and point "/img" there.
BTW, thanks for applying the patch. Infection rates were reportedly over 300,000 servers and supposedly all the infected machines are due to fire off again in 10 days time. NOT a pretty picture!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to display image files in jsp
 
Similar Threads
Image not getting displayed in JSP
dispaly image in jsp page
context path
Image Display problem
Images are not coming in JSP pages