PDA

View Full Version : Using a PDF as a view


sbrummer
Aug 13th, 2007, 11:18 AM
Hello,

I am trying to use various static PDF files as the resulting Controller view in a Spring MVC implementation.

I can do a redirect to a publicly accessible PDF file in my Controller and it works great but I need the PDF files to be stored in an non public folder (i.e. “WEB-INF/pdf/myfoldername/myfilename.pdf”).

I can’t seem to find a configuration in the Spring viewResolver or other solution to make this happen.

Any thought or suggestion would be appreciated.

Thanks

Sbrummer

dr_pompeii
Aug 13th, 2007, 04:57 PM
I need the PDF files to be stored in an non public folder (i.e. “WEB-INF/pdf/myfoldername/myfilename.pdf”).

i have a simple suggestion,
i think that some controller should open your myfilename.pdf right?

ok, if the answer is yes, you can use acegi to control the access for action/controller before to open some pdf, and you can have the folder in a public place

HTH

regards

Jörg Heinicke
Aug 13th, 2007, 10:59 PM
I can do a redirect to a publicly accessible PDF file in my Controller and it works great but I need the PDF files to be stored in an non public folder (i.e. “WEB-INF/pdf/myfoldername/myfilename.pdf”).

This is a valid use case for going without a view. Therefore you create something like a DownloadController and it writes the PDF into the response's OutputStream. Instead of a ModelAndView instance the controller is supposed to return null in case of handling the response itself. See the 4th paragraph of the introduction of MVC (http://static.springframework.org/spring/docs/2.0.x/reference/mvc.html) in the reference.

Joerg