jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes Servlet can't find Image file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet can Watch "Servlet can New topic

Servlet can't find Image file.

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1130
I have an ad banner (just an IMG tag for now) that displays when the user first goes to the main JSP page in my application.
However when he gets re-directed to a page in the WEB-INF directories after leaving the first JSP page (where the img does display), the IMG file no longer displays on the next JSP page.
>> I'm using Tomcat <<
I've tried putting the image in various directories (like 'lib'), including the classes folder, but Tomcat doesn't seem to be able to find it. (Though Tomcat does find it in the folder where the first JSP page is.)

Can anybody tell me where to put the IMG so it can be found when the servlet re-directs the first JSP page (Login) to another page?
Thanks much!
-- Mike
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
A web server can't directly serve any file from WEB-INF - you have to put the image file in with normal application html or jsp files. The problem is that without an absolute URL, the browser is looking for the file relative to where the page is coming from. I like to use a BASE tag in the HEAD area of the generated HTML page to tell the browser where to look for resources like CSS files, images, etc.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1130
Thanks Bill!
-- Mike
I agree. Here's the link: http://aspose.com/file-tools
subject: Servlet can't find Image file.
It's not a secret anymore!