wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "JSR-286 question: Portlet / serveResource" Watch "JSR-286 question: Portlet / serveResource" New topic
Author

JSR-286 question: Portlet / serveResource

Hub Fel
Greenhorn

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.
Question:
How do I achieve to display a PDF as response to a RenderRequest in doView()?

Thank you
Hubert
Hub Fel
Greenhorn

Joined: Oct 21, 2009
Posts: 10
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)

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JSR-286 question: Portlet / serveResource
 
Similar Threads
Portlet Cacheability Levels
images are not displayed in the portlet ... Please help
Page Forward in Portlets
is session always required to accomplish this?
processAction method doubt