I am very new to portlets development. I am currently facing the following issue.
We are retriving an xml file from one of the datasource. This xml has images embeded in it. to retrive these images we need to connect to the database again. this reconnect is done by one of the servlet.
we are using an xsl file to do the transformation of the above link, after transformation:
now we do a encodeURL of this:
the final image tag is now:
Please note in the above link "imageServlet" is the Servlet which has the code that connects to datasource to retrive the image
the final image tag is retrived in the jsp file.
then we display the html as in below:
When i do the above steps i am supposed to get the images when docdisplay.jsp is accessed. But i get X in place of the images.
Could anyone please tell me why the imageservlet doGet method not getting executed at
My docDisplay.jsp has
<%@ taglib prefix="portlet" uri="http://java.sun.com/portlet"%>
So is there some thing to do with JSR168 and JSR286 usage???
I dont if what i have made my explanation short and clear.
Is your final image tag showing src attribute like
If so , are you able to access the image servlet directly in the browser (outside portal) and able to see the image ? If you are not able to see the image by hitting the servlet directly, it can be an issue with setitng the right mime type in servlet respose.
Which version of Portlets you are using ? In JSR286, we have a serveResource() method that can be used here, instead of an extra servlet. But again, make sure you are setitng the correct mime type before serving the resource.
Joined: Jan 17, 2011
Thanks a lot for your reply.
the final img tag is the encoded url
i tried to write a simple code which had
the servlet was then getting called properly but with the wsrp_rewrite?wsrp-urlType=resource&wsrp-url..... the servlet is not called.
Could you please tell me how we can set the mime type in servlet respose.
We are just adding the html content to modelview and then in the jsp we are accessing the html
Well first things first, using servlet inside a portlet app is not appropriate (rather dumb).
Since as you specified you are using portlet 2.0 spec in portlet.xml, you can certainly use serveResource method (GenericPortlet 2.0 method).
It is made for such purposes only.
So in your jsp instead of response.encodeUrl(), use:
Also note that the implicit response availble in jsp is actually instance of RenderResponse.
You can check it by typing <%=(response instanceof javax.portlet.RenderResponse) %> on jsp. It should print true.
Above will do the job. Although I strictly recommend not to use scriplets in you code.
Instead pass this url via render/doView etc method.
Besides, you are facing difficulty because RenderReponse.encodeUrl() does not guarentees a valid url.
To know more read here (portlet javadoc).
Don't forget to add reps if you like my reply.
SCJP 91%, SCWCD 97%
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: images are not displayed in the portlet ... Please help