Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access gif files from servelets

 
Ben Field
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need my servelet to use a GIF file. I have tried placing he gif file in the following locations:

c:\Tomcat 4.0\
c:\Tomcat 4.0\webapps
c:\Tomcat 4.0\webapps\myapp\
c:\Tomcat 4.0\webapps\myapp\classes

And I have tried refering to the gif in the following manner:
out.println("<IMG SRC=tick.gif'></TD>");
out.println("<IMG SRC=/tick.gif'></TD>");
out.println("<IMG SRC='myapp/tick.gif'></TD>");
out.println("<IMG SRC='/myapp/tick.gif'></TD>");

Do I have to specify the exact path?

Thanks
Ben
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should deploy the image file to somewhere in the public part of your application (in the case of Tomcat, this is some path under the docBase which isn't /WEB-INF/).

You then need to use a link which corresponds to the location of the file as seen by a browser. It's difficult to say much more without knowing where you publicly want the image to be accessible from, and how your domain is configured. It might be a good idea to use the opening / (absolute path) or it might not be (relative path), it depends on what you're trying to do.

More information would be helpful - for example, what URL are you currently accessing the application via?
 
Darren Edwards
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Should work assuming you are accessing your application with a URL such as
http://localhost:8080/myapp
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic