PDA

View Full Version : download portlet controller


remi.degruson
Jun 6th, 2006, 10:40 AM
Hi spring forum,

How to download from a portlet ?

My domain class create a pdf and the controller want to send it to the browser.
I don't want to use org.springframework.web.servlet.view.document.Abst ractPdfView
since I create the pdf using gnupdf.

I thought to just do something like response.getOutputStream.write((byte[])request.getAttribute("pdf")); in a jsp, but
response.getWriter() is called by another class, so I can't.

This forum contains some topics related download with servlet but none with portlet. The simplest way should be to call a servlet, how can I do that ?

Thanks for any help,
Rémi

remi.degruson
Jun 9th, 2006, 09:22 AM
Finally, I do that :
public class PdfController implements Controller {
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception {
File pdf = new File(request.getPortletSession(true).getPortletCon text().getRealPath("/")+"etus.pdf");
...
out.print("\n<a href=\""+request.getContextPath()+"/etus.pdf\"> youpi</a>");
...
return null;
}
}

It's not beautiful, but I don't hope anybody will help me :-(

Rémi

johnalewis
Jun 30th, 2006, 05:24 PM
There is an answer for this in the new FAQ section on the Spring Portlet MVC wiki site:

http://opensource.atlassian.com/confluence/spring/x/PAw