Solved

How to get resource from WEB-INF

Posted on 2010-09-06
10
515 Views
Last Modified: 2012-06-27

I want an image to load in browser from web-inf.
0
Comment
Question by:mihir_amreli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33610314
directly give the path as

http://<ipaddress or host name>/<<applicationName>>/<<path from web-inf>>
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33610400
Sorry i mis-interpreted your question,
this should help
http://java.itags.org/jsp/202863/
0
 
LVL 11

Expert Comment

by:Manish
ID: 33610751
Directly from web inf is not possible.
User servlet.
http://www.exampledepot.com/egs/javax.servlet/GetImage.html
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:Hegemon
ID: 33610858
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
 

Author Comment

by:mihir_amreli
ID: 33615272
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
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33615325
you can see the correct mime type of a file using
http://www.rgagnon.com/javadetails/java-0487.html
0
 

Author Comment

by:mihir_amreli
ID: 33615480
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
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 33615602
I think mime type is different
http://www.kattare.com/docs/faq_view/822
0
 

Author Closing Comment

by:mihir_amreli
ID: 33616612
Problem Solved.
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question