• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"Simple" Download File/Resource from a JSF/Portlet

 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,

I'm quite new to portlets. I'm coding against JSR 168. I want to create a simple link which gives the user the possibility to download a file (e.q. a PDF-document) form my portlet. I spent several hours with searching for a solution, but without any success. In the forum I've found several requirements (http://www.coderanch.com/t/457396/Portals-Portlets/java/Invoking-Download-servlet-from-JSR#2040242).

I'm using a faces page to show the user my link. After he clicks on this link, the faces-action is processed in a backing bean. In the action-method of the backing bean I get the FacesContext and the file/resource, which the user wants to download. Over the FacesContext I get also the Response, but the method response.getOutPutStream() always return null, and so a NullPointerException is thrown. I don't understand why I receive null and how I can solve this problem.

A way what I've seen is to redirect (redirect/forward/include ???) to another servlets which provides the download function. I've tried this too, and so integrated in my portlet just an plain JEE-servlet and create the required entries in the web.xml. I'm not able to call this servlet from my portlet/backing bean. I don't also not understand why I've to use a internal servlet to provide a simple file-download.

I hope someone can provide some clarification for me.

Thanks and best regards,
Christian Nicoll
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has nobody made some experience for this problem or can someone provide a code example?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic