How to get resource from WEB-INF


I want an image to load in browser from web-inf.
mihir_amreliAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Gurvinder Pal SinghConnect With a Mentor Commented:
I think mime type is different
http://www.kattare.com/docs/faq_view/822
0
 
Gurvinder Pal SinghCommented:
directly give the path as

http://<ipaddress or host name>/<<applicationName>>/<<path from web-inf>>
0
 
Gurvinder Pal SinghCommented:
Sorry i mis-interpreted your question,
this should help
http://java.itags.org/jsp/202863/
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ManishLeadCommented:
Directly from web inf is not possible.
User servlet.
http://www.exampledepot.com/egs/javax.servlet/GetImage.html
0
 
HegemonCommented:
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)
0
 
mihir_amreliAuthor Commented:
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.
0
 
Gurvinder Pal SinghCommented:
you can see the correct mime type of a file using
http://www.rgagnon.com/javadetails/java-0487.html
0
 
mihir_amreliAuthor Commented:
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".
0
 
mihir_amreliAuthor Commented:
Problem Solved.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.