Solved

How to get resource from WEB-INF

Posted on 2010-09-06
10
507 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

708 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

16 Experts available now in Live!

Get 1:1 Help Now