-
1. Re: image/png Content type not accepted
seansullivan Oct 24, 2006 4:46 PM (in response to jgilbert)I encountered the same problem. I have a portlet that produces a PNG image. The portlet writes the PNG data to the PortletOutputStream.
I am using jboss-portal-2.4.1-cr1 (JBoss Portal + JBoss bundle) -
2. Re: image/png Content type not accepted
seansullivan Oct 24, 2006 4:53 PM (in response to jgilbert)I found a flaw in my portlet.xml file:
<supports> <mime-type>text/html</mime-type> <portlet-mode>EDIT</portlet-mode> <portlet-mode>VIEW</portlet-mode> <portlet-mode>HELP</portlet-mode> </supports>
I'll change the mime-type to image/png and post the results later today. -
3. Re: image/png Content type not accepted
seansullivan Oct 25, 2006 1:42 AM (in response to jgilbert)I fixed my portlet.xml file but I don't think JBoss Portlal can handle a portlet that produces image/png data.
On the OpenSymphony message board, I found a discussion about producing image output from a portlet:
http://forums.opensymphony.com/message.jspa?messageID=52699
Nils-Helge Garli wrote:
> Hm... I might have been wrong about it. Maybe you can't generate
> image output from a portlet. Didn't see anything about that in the
> portlet spec (maybe someone can enlighten me?).
There's nothing that prohibits it, but there's also nothing that
supports it, other than the call to response.setContentType();
What a portal has to do is define a custom window state that says
"display only this portlet". When the portlet is rendered with such a
state it can assume that it will "own" the output, and can thus create
images or Excel reports or whatever.
The usual workaround for portals that doesn't have such a window state
is to link to a servlet that can generate the data instead. Using a
servlet is worse, however, since it cannot leverage any security
configuration that a portlet would be able to, and would have to ensure
on its own that any call is legitimate. But sometimes that is ok.
/Rickard -
4. Re: image/png Content type not accepted
seansullivan Oct 25, 2006 2:40 AM (in response to jgilbert)In the Portle 2.0 specification, the portlet class may implement the javax.portlet.ResourceServingPortlet interface
public interface ResourceServingPortlet
The ResourceServingPortlet interface allows serving resources through the portlet.
The portlet container must call this method for links created by the RenderResponse.createResouceURL() call. If the portlet creates resource URLs with RenderResponse.createResouceURL() it must implement this listener.
The ResourceServingPortlet interface contains this method:
void serveResource(ResourceRequest request,
ResourceResponse response)
throws PortletException,
java.io.IOException
Called by the portlet container to allow the portlet to generate the resouce content based on its current state. The portal / portlet container must not render any output in addition to the content returned by the portlet. The portal / portlet container should expect that the portlet may return binary content for a renderResource call. -
5. Re: image/png Content type not accepted
seansullivan Oct 25, 2006 2:50 AM (in response to jgilbert)
This presentation discusses resource serving portlets in JSR 268:
http://www.us.apachecon.com/presentations/FR8/FR8-JSR-286-updated.pdf -
6. Re: image/png Content type not accepted
roy.russo Oct 26, 2006 11:34 AM (in response to jgilbert)We don't support Portlet 2.0, yet.
So to serve your binaries, you will have to dispatch to a servlet, from the portlet, and have the servlet stream the binary. -
7. Re: image/png Content type not accepted
avalendino Jul 25, 2008 6:59 AM (in response to jgilbert)Hi all
i hai the same problem discussed here but i'm going to fighting with an application/pdf mime tipe.
the proble is analogous, what change is the type of output returned.
I have developed a CMS portlet that contain a link to my PDF file that is stored in the CMS too, but now i need to open the pdf content only within a window, reading the PDF file from a CMS
I have already set the returned mime type in my portlet implementation
rResponse.setContentType("application/pdf");
and in my portlet.xml
<mime-type>application/pdf</mime-type>
but as result i have only seen a "wonderful", unlimited stack trace in my server's log that say:
java.lang.IllegalArgumentException: Content type not accepted
...
<infinite stack...>
...
Caused by: javax.activation.MimeTypeParseException: Type [application/pdf] not supported
any advice will be appreciated!!!
I use jboss portal 2.6.5 -
8. Re: image/png Content type not accepted
peterj Jul 25, 2008 11:52 AM (in response to jgilbert)avelendino, you should not have attached your question to a two year old topic, you should have started a new topic instead.
The error message means exactly what is says - the only mime type supported by portlets is text/html. The only way you can supply a PDF to your users is to provide a link to the PDF within CMS. Or you could write code that reads the PDF and converts it to HTML. (Hey, a tag that did this would probably be a big hit!)