Solved

How to get resource from WEB-INF

Posted on 2010-09-06
10
510 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 50
web services creation SOAP vs REST 5 37
arguments to jar 5 26
servlet example 17 28
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

816 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now