java - Getting resource from ExternalContext in Servlet -
in bean getting url of image this:
externalcontext ec = facescontext.getcurrentinstance().getexternalcontext(); url url = ec.getresource("/myimagedirectory/image.png");
how can in httpservlet?
i tried following, did not work:
servletcontext sc = getservletcontext(); url url = sc.getresource("/myimagedirectory/image.png");
the httpservlet in same application bean.
getservletcontext().getrealpath("/")+"/myimagedirectory/image.png";
the "/" represents web content root.
Comments
Post a Comment