Solved

Access file from war web application

Posted on 2003-11-03
3
230 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
iterator example remove 8 74
'exit' is not valid keyword in java 14 134
How to set default webapp for host 6 41
maven project jars 7 46
Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
A Short Story about the Best File Recovery Software – Acronis True Image 2017
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

18 Experts available now in Live!

Get 1:1 Help Now