File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

sahana nc

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.

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

My docDisplay.jsp has
<%@ taglib prefix="portlet" uri=""%>

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

Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
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

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
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%
I agree. Here's the link:
subject: images are not displayed in the portlet ... Please help
It's not a secret anymore!