title: New uploaded files and Tomcat?
body: <p>I have a simple servlet for images uploading, a user select an image and the servlet does its job and then write it to <em>upload</em> directory. My project layout:</p>
  
  <pre><code>project
      ├───static
      │   ├───img
      │   └───js
      ├───upload
      └───WEB-INF
          └───lib
  </code></pre>
  
  <p>After uploading the image, the user is redirected to it's location:</p>
  
  <pre><code>http://localhost:8080/upload/[image MD5 hash].png
  </code></pre>
  
  <p>The uploading code works pretty well, but Tomcat returns 404 error when requesting the url even when the image is there:</p>
  
  <pre><code>&gt; wget http://localhost:8080/upload/f5d1da2cadf3bd1c1b9196ec522a5d73.png
  SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
  syswgetrc = C:\GnuWin32/etc/wgetrc
  --2013-01-16 03:45:33--  http://localhost:8080/upload/f5d1da2cadf3bd1c1b9196ec522a5d73.png
  Resolving localhost... 127.0.0.1, ::1
  Connecting to localhost|127.0.0.1|:8080... connected.
  HTTP request sent, awaiting response... 404 Not Found
  2013-01-16 03:45:33 ERROR 404: Not Found.
  &gt; 
  </code></pre>
  
  <p>After I click <code>update classes and resources</code> in my IDE, Intellij, it works:</p>
  
  <pre><code>&gt; wget http://localhost:8080/upload/f5d1da2cadf3bd1c1b9196ec522a5d73.png
  SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
  syswgetrc = C:\GnuWin32/etc/wgetrc
  --2013-01-16 03:48:11--  http://localhost:8080/upload/f5d1da2cadf3bd1c1b9196ec522a5d73.png
  Resolving localhost... 127.0.0.1, ::1
  Connecting to localhost|127.0.0.1|:8080... connected.
  HTTP request sent, awaiting response... 200 OK
  Length: 11666 (11K) [image/png]
  Saving to: `f5d1da2cadf3bd1c1b9196ec522a5d73.png'
  
  100%[==========================================================&gt;] 11,666      --.-K/s   in 0s
  
  2013-01-16 03:48:11 (72.9 MB/s) - `f5d1da2cadf3bd1c1b9196ec522a5d73.png' saved [11666/11666]
  &gt;
  </code></pre>
  
  <p>The second thing is that when I manualy delete this image, I still can download it (does Tomcat do some sort of cashing?):</p>
  
  <pre><code>&gt; del f5d1da2cadf3bd1c1b9196ec522a5d73.png
  &gt; wget http://localhost:8080/upload/f5d1da2cadf3bd1c1b9196ec522a5d73.png
  SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
  syswgetrc = C:\GnuWin32/etc/wgetrc
  --2013-01-16 04:12:25--  http://localhost:8080/upload/f5d1da2cadf3bd1c1b9196ec522a5d73.png
  Resolving localhost... 127.0.0.1, ::1
  Connecting to localhost|127.0.0.1|:8080... connected.
  HTTP request sent, awaiting response... 200 OK
  Length: 11666 (11K) [image/png]
  Saving to: `f5d1da2cadf3bd1c1b9196ec522a5d73.png'
  
  100%[==========================================================&gt;] 11,666      --.-K/s   in 0s
  
  2013-01-16 04:12:25 (93.2 MB/s) - `f5d1da2cadf3bd1c1b9196ec522a5d73.png' saved [11666/11666]
  &gt; 
  </code></pre>
  
  <p>My <em>web.xml</em> file:</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/static/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/upload/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Could someone please tell me where is the problem?</p>