Peter,

When I display images in my servlets, I don't normally define where they are
in the web.xml file. I don't know Tomcat well enough to be sure if this
approach is possible but I suspect the most common way to do it is the way I
do it.

In my case, I simply include the HTML that displays the image in the doGet()
that displays the page. This excerpt illustrates this approach:

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType(CONTENT_TYPE);

PrintWriter out = response.getWriter();

out.println("<html>");

out.println("<head>");

out.println("<title>My Title</title>");

out.println("<LINK rel=\"stylesheet\" TYPE=\"text/css\"
HREF=\"event_form.css\">");

out.println("</head>");

out.println("<body>");

out.println("<div align=\"center\">");

out.println("<table class=\"outer\" width=\"620\" cellpadding=\"8\">");

/** THE FOLLOWING IS THE RELEVANT LINE **/

out.println("<tr><td><img src=\"logo_small.gif\" alt=\"logo\"></td></tr>");

out.println("<tr><td><h2>Event Input</h2></td></tr>");


out.println("<form action=EventHandler method=POST>");

out.println("<table class=\"form\" width=\"620\" cellspacing=0
cellpadding=0>");

out.println("</table>");

out.println("</div></body></html>");

}

As long as the image is where Tomcat is looking for it, you should have no
problem. In my case, the image is sitting in the highest-level of the WAR
file.

Rhino

----- Original Message ----- 
From: "Peter Renken" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 29, 2004 2:42 PM
Subject: image not displayed



Since i am new to Tomcat i installed tomcat 5 on a Suse 8.2 linux machine
and tried to install the First Webapp Servlet example.
I have placed all files in subdirectories of myapp, thus:
myapp/src/mypackage/Hello.java,
myapp/web/WEB-INF/web.xml
myapp/web/image/tomcat.gif

After ant install and starting a local browser, the text output is shown
correctly but the image is not displayed. I cant figure out why the image
isn't shown. Did i mis something in the web.xml? (see below)

<web-app>
 <display-name>My Web Application</display-name>
 <description>This is version X.X of an application.</description>
 <servlet>
   <servlet-name>myapp</servlet-name>
  <display-name>Description of mypackage servlet.</display-name>
  <description>Description of mypackage servlet.</description>
  <servlet-class>mypackage.Hello</servlet-class>
 </servlet>
 <servlet-mapping>
   <servlet-name>myapp</servlet-name>
   <url-pattern>/</url-pattern>
 </servlet-mapping>
</web-app>

Thanks for any help.
Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to