Portlet is designed as deployable unit, so its dependen resources should be packed in the portlet application, RIGHT?
About accessing to image stored externally, i have not tried but i think it 's doable in this way
1. Get the PorltetApplication resource resolver from PortletRequestContext
2. Get the InputStream to resource
To get the PortletApplication resource resolver, we could do
public PortletApplication(PortletConfig config) throws Exception
portletConfig_ = config;
PortletContext pcontext = config.getPortletContext();
String contextName = pcontext.getPortletContextName();
applicationId_ = contextName + "/" + config.getPortletName();
ApplicationResourceResolver resolver = new ApplicationResourceResolver();
resolver.addResourceResolver(new PortletResourceResolver(pcontext, "app:"));
resolver.addResourceResolver(new PortletResourceResolver(pcontext, "par:"));
As you could see, a default resource resolver ApplicationResourceResolver is initiated/set on the portlet application
This default resource resolver enables loading external resources
i find that this topic's problem is similar to http://community.jboss.org/thread/155344.
Ideally your portlet war could serve as both portlet provider and resource provider. that is to use absolute path for resources in the portlet like :
Notice that the portletContextPath can be taken out from RenderRequest.getContextPath() when rendering.
thank both for your comments.