I wrote a little Java servlet that would dynamically generate an image button given parameters including label, height, width and so on, and it would add each new one to a cache. It worked fine, BUT it required a servlet call for every call to display the button or its highlighted version. I dumped the cache and made PNG files of all the buttons used at the moment in the app, added those files to the app so they could be referenced by "/images/button/xyz.png", where the filename is a hash of the input parameters.
That works fine, but I want my original servlet to be called on the occasion when someone has added a new button. I use a custom tag to define these buttons, so the tag handler gets called when the JSP compiles... so I have a point where I can choose to use one of the pre-generated buttons, OR generate a reference to the servlet so it can render the button when it is displayed.
My question is: How can I detect the image is available in pre-rendered for? I'm not sure that a call to create a URL object based off the full path and then doing a call to getResource() is the answer -- I don't want it to load the image at this time, I just need to know if it exists.
Is there some way to create a File object that would take a relative URI and allow me to test for existence?