a very simple question - outputting images from a servlet
"Carter, Scott" <[email protected]>
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <92EFB80E551BD511B39500D0B7B0CDCC0715150C@ohms.electric.ci.austin.tx.us> |
I have a servlet that builds up a web page ( an actual coded servlet, not a
jsp - yes I realize that I am not using a MVC architecture) and part of the
servlet outputs an image. I moved my web application from tomcat 3 to
tomcat 4. The problem is the code that properly output the image in tomcat
3 does not properly output the image in tomcat 4. Below is the piece of
code.
out.println("<img src=\"../../myimage.gif\"/>");
The image is sitting in the webapps/mywebapp directory. Since the servlet
class is in the webapps/mywebapp/WEB-INF/classes directory it would seem
that this is the proper path to the image (as it works under tomcat 3).
When executed under tomcat 4 the composed page trys to point to the image as
www.mywebapp.com/servlet/myimage.gif where the actual image is
www.mywebapp.com/myimage.gif .
My real question is : is there a better way to give paths to images than the
above. One idea was possibly declaring a variable in web.xml that contained
the path to my web app and declaring the rest of the path to the image in
the code. Any ideas, best practices?
Thanks - Scott
___________________________________________________________________________
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