Unable to view images in dynamically created html from java servlet running on tomcat
Posted on 2004-03-29
This is driving me nuts! If anyone can solve this for me I will be eternally grateful.
I'm using a java servlet to generate html with images in it, running on tomcat 5.
The image paths i'm using need to be relative otherwise I'm going to have to change and recompile vast ammounts of servlet code in the future.
A simple example of my problematic servlet code would be:
public class test extends HttpServlet
public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
PrintWriter writer = response.getWriter();
The generated page does not display the image, even though i'm sure i have it in the correct directory
I have tomcat installed in the default directory c:\jwsdp-1.3, thus i store my compiled servlets in:
The tomcat manual states:
...you will end up with the following contents in your application's "document root" directory:
This leads me to believe if I put 'image.gif' in:
and use the above servlet to generate:
the graphic should be displayed? yeah? no!
I've tried changing the context path in the server.xml file, it didn't work, but i'm not totally convinced i know what i'm doing with regard to this and I can't understand why I would have too anyway as I'm using the default webapps directory.
Can I give this question a million point value and get it solved in ten minutes? Serriously though, its reasonably urgent, if anyone could have a crack at it sooner rather than later I promise I will buy them a pint when I see them next in the pub.
Thanks in advance.
Best Regards, Adrian