[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Access file from war web application

Posted on 2003-11-03
3
Medium Priority
?
238 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 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In this article I will be showing you how to subnet the easiest way possible for IPv4 (Internet Protocol version 4). This article does not cover IPv6. Keep in mind that subnetting requires lots of practice and time.
Social messanging services like WhatsApp and Facebook can help businesses in ways that many owners don't even imagine, giving new opportunities to connect with customers. Discover some of the most innovative things they can do for your company.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

834 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