title: How to output an image on file as an HTML <img> from a Java Servlet?
body: <p>I have a servlet, Starter.java, in whose doGet() method I use a PrinterWriter object to print HTML. </p>
  
  <p>I have an image file: <code>C:/.../Entertainment_mgmt/src/images/logo.png</code> (inside my project), which I would like to display a Servlet page which I fetch from my localhost, at <code>localhost:8084/Starter</code>. The page also has other HTML structures, which I would like to retain (that is, I would like to fit the image in a  on a small section of the screen). Simply outputting <code>&lt;img src="C:/.../Entertainment_mgmt/src/images/logo.png" /&gt;</code> to HTML does not seem to work.</p>
  
  <p>I've not performed any manual servlet mapping and I haven't changed any of Tomcat's configuration files.</p>
  
  <p><a href="https://i.stack.imgur.com/62Wkh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/62Wkh.png" alt="enter image description here"></a></p>
  
  <p>I have checked many similar posts, but I just can't seem to get a hang of it. </p>
  
  <p><strong>EDIT</strong>: I see that this post has been marked as a duplicate. I feel that this post still has significance due to the simple fact that other programmers might make the same mistake I did (regarding Tomcat serving images along with pages). Moreover, this provides a solution that does not require changing of Tomcat's <code>/conf/server.xml</code> file</p>