Solved

Access file from war web application

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with LDAp login using jsp 6 113
authenticate preemptively soap ui option 3 124
iterator example remove 8 74
How to Post an If Statement in JSP 3 51
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

26 Experts available now in Live!

Get 1:1 Help Now