Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Servlet can't find Image file.

 
Bartender
Posts: 1876
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Bill
 
Mike London
Bartender
Posts: 1876
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bill!
-- Mike
 
Replace the word "snake" with "danger noodle" in all tiny ads.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic