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.

more


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -