Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSR-286 question: Portlet / serveResource

 
Hub Fel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Question:
How do I achieve to display a PDF as response to a RenderRequest in doView()?

Thank you
Hubert
 
Hub Fel
Greenhorn
Posts: 10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
with the following in doView()

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

my serveResource() does
resourceResponse.setContentType(doc.getMimeType());
resourceResponse.getCacheControl().setExpirationTime(0);
OutputStream outstream = resourceResponse.getPortletOutputStream();
outstream.write(doc.getData());
outstream.flush();
outstream.close();


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
Hubert

17:55:47,953 ERROR [[WorkflowPortlet]] Servlet.service() for servlet WorkflowPortlet threw exception
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:737)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:349)
at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.ja
at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:126)
at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:570)
at org.apache.coyote.Response.doWrite(Response.java:560)
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:353)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:354)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:381)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:370)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:83)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic