I have a relatively simple Apache httpd + Tomcat via mod_jk setup that works well, but I need to have Tomcat handle certain 404 conditions. Basically, the httpd service will handle images and PDF files and the occasional IIS hacking attempt. However the PDF files are actually created by Tomcat and deleted from the filesystem later, and some people have placed links to those volatile PDF documents out on the web. This results in 404 messages, when what I really want is to have the user see the form where the PDF was generated from.
I can, of course, have Tomcat handle all 404s:
ErrorDocument 404 /404.jsp
But there are too many of them, and Tomcat just sees 404.jsp, it doesn't know what the original URL was. What I need is:
- httpd continues to serve up all images, PDFs, etc.
- if a PDF file is missing, send that request through mod_jk. For all other types, it continues to respond with its own 404.
- Tomcat figures out where the PDF really came from and forwards the user on to that page.
Is this doable without too much .conf surgery?