It's not a secret anymore!*
The moose likes Portals and Portlets and the fly likes images are not displayed in the portlet ... Please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "images are not displayed in the portlet ... Please help" Watch "images are not displayed in the portlet ... Please help" New topic
Author

images are not displayed in the portlet ... Please help

sahana nc
Greenhorn

Joined: Jan 17, 2011
Posts: 2
Hello All,

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.

the xml part which refers to image is


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.
docDisplay.jsp


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



More info:
portlet.xml has
<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
version="2.0">


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.

Anyone please help


Thanks a lot for your response

Regards,
Sahana....
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
Hi,
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.
sahana nc
Greenhorn

Joined: Jan 17, 2011
Posts: 2
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


Please check out the following link .... My issue is same like below
http://www.liferay.com/web/guest/community/forums/-/message_boards/message/219515
http://forums.oracle.com/forums/thread.jspa?threadID=1116032&tstart=0
Shashank Ag
Ranch Hand

Joined: Dec 22, 2009
Posts: 88

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%
 
Consider Paul's rocket mass heater.
 
subject: images are not displayed in the portlet ... Please help
 
Similar Threads
How can I tell if my portlet is JSR 168 or 286 compatible?
navigation between the pages in different portlets using JSR286
Deployed portlets do not show up in Jetspeed
problems showing a very simple portlet in pluto
Portlet Data sharing using liferay and icefaces