This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Portals and Portlets and the fly likes JSR-286 question: Portlet / serveResource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "JSR-286 question: Portlet / serveResource" Watch "JSR-286 question: Portlet / serveResource" New topic

JSR-286 question: Portlet / serveResource

Hub Fel

Joined: Oct 21, 2009
Posts: 10
Hi all,

In doView() I want to display a PDF form, so I call response.createResourceURL() within doView() and expect that my serveResource() function will be called, but this does not happen -- i get a blank page (there is no other output). The created resource URL is OK, if I copy/paste it to the browser, my serveResource() is called and the PDF is displayed.
How do I achieve to display a PDF as response to a RenderRequest in doView()?

Thank you
Hub Fel

Joined: Oct 21, 2009
Posts: 10
with the following in doView()

PrintWriter writer = response.getWriter();
ResourceURL resURL = response.createResourceURL();
String p = "<object data=\"" + resURL.toString() + "\"" + "type=\"application/pdf\" width=\"100%\" height=\"100%\"";

my serveResource() does
OutputStream outstream = resourceResponse.getPortletOutputStream();

this works for IE and firefox but....
in IE without problems, in firefox I get a Stacktrace although I get the document in the browser, but sometimes firefox also crashes

Does someone perhaps have a clue?
Thank you

17:55:47,953 ERROR [[WorkflowPortlet]] Servlet.service() for servlet WorkflowPortlet threw exception Connection reset by peer: socket write error
at Method)
at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(
at org.apache.tomcat.util.buf.ByteChunk.append(
at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.ja
at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(
at org.apache.coyote.http11.InternalOutputBuffer.doWrite(
at org.apache.coyote.Response.doWrite(
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(
at org.apache.tomcat.util.buf.ByteChunk.append(
at org.apache.catalina.connector.OutputBuffer.writeBytes(
at org.apache.catalina.connector.OutputBuffer.write(
at org.apache.catalina.connector.CoyoteOutputStream.write(
at org.apache.catalina.connector.CoyoteOutputStream.write(

I agree. Here's the link:
subject: JSR-286 question: Portlet / serveResource
It's not a secret anymore!