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
Solved

How to get resource from WEB-INF

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

I want an image to load in browser from web-inf.
0
Comment
Question by:mihir_amreli
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
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.

 
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
 
LVL 92

Expert Comment

by:objects
ID: 33613789
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 115
session migration servlets 2 42
xampp tool 12 56
jmss example java 2 23
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

840 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