How to stream a file out of portlet ActionResponse in JBoss Portal?

Solution Verified - Updated -

Issue

What is the correct/supported way to download a file, such as a spreadsheet, to the browser from a portlet? In a stand-alone application, I can do the following, but it doesn't work from the portlet:

    // Set the content type for the response
    response.setContentType("application/vnd.ms-excel");

    // Open the output stream 
    outputStream = response.getOutputStream();

    // Generate content and write it to the output stream 
    createRows(outputStream);

    // clean resources
    outputStream.flush();
    outputStream.close();

Environment

  • JBoss Enterprise Portal Platform (EPP)
    • 4.3
    • 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In