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

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -