Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to get resource from WEB-INF

Posted on 2010-09-06
10
Medium Priority
?
520 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:Gurvinder Pal Singh
ID: 33610314
directly give the path as

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

Expert Comment

by:Gurvinder Pal Singh
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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:Gurvinder Pal Singh
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:
Gurvinder Pal Singh earned 1500 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

604 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