|
Home > Archive > WebSphere Portal Server > March 2004 > How to get Outputstream
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to get Outputstream
|
|
| Robin 2004-03-30, 11:37 am |
| Hi all,
I am now using WPS 5 to develop a Portlet App, and the
customer requirement need us to create and download Excel file
with the query result from database.
Now I use the code as below:
....
workBook.output(((PortletResponse) response).getOutputStream());
....
The workBook object is the Excel object created with my query result.
But I got the IllegalStatement exception when program run this line.
Does WPS prohibit the using of response object? Thx!
| |
| Michael Harris 2004-03-30, 3:33 pm |
| You can't output an Excel spreadsheet from inside a portlet during it's
service (doView, doHelp, etc) method processing. Output from a portlet is
combined with other portlets and themes and skins to build up a single HTML
page to send to the browser. You can't just dump the bytes of a spreadsheet
(or any other object such as graphics) into an HTML stream.
What you need to do is write a servlet that outputs these bytes and package
it with your portlet. Then your portlet needs to write out a URL to the
servlet into the HTML stream that will cause the browser to invoke it and
retrieve the bytes for the spreadsheet when needed.
Remember: A portlet's output is ALWAYS included into the middle of a bigger
HTML (or WML, or whatever markup) page... It is NEVER the entire page as it
can be in servlet programming.
|
|
|
|
|