Solved

Access file from war web application

Posted on 2003-11-03
3
232 Views
Last Modified: 2010-04-01
How can I read ONE file say from multiple beans (different packages) and ensure that the application can find it on the server in the war?
0
Comment
Question by:sapientconceptions
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
kennethxu earned 125 total points
ID: 9675662
use ServletContext.getResourceAsStream() to access any file in the war
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getResourceAsStream(java.lang.String)

or

use getClass().getClassLoader().getResourceAsStream() to access files in WEB-INF/classes:
http://java.sun.com/products/jdk/1.2/docs/api/java/lang/ClassLoader.html#getResourceAsStream(java.lang.String)
0
 

Author Comment

by:sapientconceptions
ID: 9719058
thanks!
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9719502
glad that I can help.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
best way to search/remove a file from an EAR file 3 109
Clear browser cache on site login, is it possible? 3 27
oracle fusion vs MQ 2 114
withoutString  challenge 40 198
The question appears often enough, how do I transfer my data from my old server to the new server while preserving file shares, share permissions, and NTFS permisions.  Here are my tips for handling such a transfer.
February 24, 2017 — On February 23, Travis Ormandy, a vulnerability researcher at Google, reported on Twitter (https://twitter.com/taviso/status/834900838837411840) that massive stores of data have been leaked by CloudFlare, a company that provide…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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