Link to home
Start Free TrialLog in
Avatar of mihir_amreli
mihir_amreli

asked on

How to get resource from WEB-INF


I want an image to load in browser from web-inf.
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

directly give the path as

http://<ipaddress or host name>/<<applicationName>>/<<path from web-inf>>
Sorry i mis-interpreted your question,
this should help
http://java.itags.org/jsp/202863/
Directly from web inf is not possible.
User servlet.
http://www.exampledepot.com/egs/javax.servlet/GetImage.html
WEB-INF is a special place the browser has no access to.
Use a servlet streaming the resource as

Thread.currentThread.getContextClassLoader().getResourceAsStream ("WEB-INF/someFile.jpg)
Avatar of mihir_amreli
mihir_amreli

ASKER

As per your response

Directly from web inf is not possible.
User servlet.
http://www.exampledepot.com/egs/javax.servlet/GetImage.html

I am able to load image in browser.
I am also enable to download .doc file
Thank you.

but not .docx because

getServletContext().getMimeType(filename) return null for .docx file.

Please Help.
you can see the correct mime type of a file using
http://www.rgagnon.com/javadetails/java-0487.html
I got content type using getServletContext().getMimeType(fileName);

but I am getting "MIME-TYPE"  null for the file which has extension is .docx

with .doc i am getting application/msword "MIME-TYPE".
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Problem Solved.