I don't have a solid knowledge of java servlet but i believe the same idea will work.
In PHP i would just create a directory with a script that return the content type image/* so for instance
/Document/index.php
with the following content
<?php
$getVar=$_GET;
// do the necessary with the get vars
header('Content-Type:image/jpg');// you can adjust the content type accordingly
/* this is the image url. you can use
.htaccess and get this as the last parameter of the url just like in your question */
readfile('myimg.gif');
To make the url just like what you have currently - .htaccess will help to rewrite the url to look pretty much like anything, even take multiple images/actions with switch
statement or if
on the back-end
<img src="/Documents/myimg.gif?utm_source="myfile"/>
Again this is for PHP but you should get an idea.