Question: From within an HttpServlet doGet method, is it possible to know whether the servlet URL was accessed via an IMG SRC, as opposed to being typed in a browser address bar?

**UPDATE**

This is my actual HTML.

```
<a href="#" onclick="openwindow('/image/display?imageId=${image.id}'); return false;"><img width="50px" alt="${image.originalName}" src="/image/display?imageId=${image.id}" /></a>

```

As you can see, it displays a small thumbnail, inline in the page, but if you click on it, it opens full-size in a new window.

My DisplayImageServlet is behind /image/display. I need some slightly different logic inside the servlet for thumbnail as opposed to full-size.

Ideally I would like a solution that does not involve changing the HTML references. Other developers in my team may add HTML references to the servlet and not appreciate the subtlety.

Answer: 
Not directly that I'm aware of, but you could do something like add a header to the request if it's sent via the image src. That way your request payload is identical in all cases, but you can still identify where in your application the request came from. For example, you could use the "referer" header, the contents of which would be "<http://www.yoursite.com>" when called directly, or "<http://www.yoursite.com/images/linkImage.png>" when called via the image src.

EDIT:
Following a lovely discussion, I thought it might be best to explain exactly how this would work. First of all, rather than the value coming from the servlet at the point where it produces the HTML page to return to the client, it would happen in the client. So the process would be something like this:

* Client makes request to servlet
* Servlet returns HTML page where rather than specifying the src in the img tag (actually, src should probably be filled with a dummy/backup) the onload attribute points to javascript function that
will set the image src.
* Javascript function calls something on your server to retrieve the image src. At this point you can add headers to your
request.
* Servlet receives the request and can tell by the presence/value of the header where the request came from.
If it is doGet() then it should attach parameter into url path and you should be able to get that parameter using request.getParameter() in your code.