Re: a very simple question - outputting images from a servlet

Dave Ford <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <007601c318fc$ac440530$be7ba8c0@davetoshiba>
> I have a servlet ...  Below is the piece of code.
> out.println("<img src=\"../../myimage.gif\"/>");
There is no guarantee that relative paths from a servlet will work.

>  is there a better way to give paths to images than the above.
Why not just use a "web app relative" path. For example, suppose the
following directory structure:

c:\[tomcat]\MyWebApp\images\myimage.gif

Just use the following tag:

<img src="/images/myimage.gif"/>

Dave Ford
Smart Soft - The Developer Training Company
http://www.smart-soft.com

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.