• Post Reply Bookmark Topic Watch Topic
  • New Topic

URL Rewrite for different output formats

 
Scott Selikoff
author
Bartender
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!