I have a servlet that can return data in multiple output formats including pdf, excel, html. Generating the files and setting the content works fine, but I'd like to rewrite the request URL (if possible) for a more standard output. For example, if the user requests "print.jsp", I would like the URL rewritten to "print.pdf" for PDF and "print.xls" for Excel files, so that when a user goes to save the files, that is the name they get automatically. Currently if they go to save, they get print.jsp. Also, my browser is finicky and without the ".xls" it just wants to save Excel files to disk instead of open in the browser (even though content type is set to excel).
Is rewriting the request URL possible or does it require (trying to avoid) a redirect?
Also, I'm currently using an event-based architecture with forwarding built in, but it doesn't seem to work, in particular I'm using:
Where print.pdf is the name of the PDF I want to rewrite the URL to. This type of forwarding does not seem to change the URL value though. [ July 05, 2007: Message edited by: Scott Selikoff ]
Scott, Have you tried setting the Content-Disposition header? This header allows you to specify the saved file's name as well as suggest whether the browser should display the file with the associated application in line or promp the user with a save/open dialog box.