Re: a very simple question - outputting images from a servlet
Tom K <[email protected]>
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <000001c3190f$43968e50$6401a8c0@developer> |
Scotty "we need all the power you can give us!" request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/clingon" "But captain, we are using all the power we have; we just can't give it anymore!" Better check your diletheum crystals. T.K. -----Original Message----- From: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology. [mailto:[email protected]] On Behalf Of Carter, Scott Sent: Monday, May 12, 2003 4:57 PM To: [email protected] Subject: a very simple question - outputting images from a servlet 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 ___________________________________________________________________________ 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