• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image URLs in CSS

 
Mark Beavis
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there -

I'm trying to develop a .jsp fragment for fora portlet. In the jsp I'm including some inline css.

The css needs to include some images, for example:

.dialog_nw {
background: transparent url(default/top_left.gif) no-repeat 0 0;
}

My question is how to I supply the correct URL to this image? I tried the <portlet:renderURL />/default/top_left.gif tag, but that did not work.

Any ideas?

Thanks
 
Hemant Sharma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The encodeURL method of the RenderResponse object creates the correct link to other resources within the portlet (images, JSPs, applets, etc.). A root relative path is passed to this method. To obtain the correct path use the RenderRequest.getContextPath() method to prepend your path.

In the above case the url will be something like <%= renderResponse.encodeURL(renderRequest.getContextPath() + "/default/top_left.gif")%>
 
Umesh Wale
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JSP we can always try this using the Portlet tld as below,
<portletAPI:encodeURI path='images/A.gif'/>

Import the Portlet.tld
and instantiate PortletApi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic