Skip to Content
author's profile photo Former Member
Former Member

Cannot read Property file from JSP in a Web Module Project

I have tried to read the properties file in two ways but am not able to read it because i cannot find the correct path of the properties file.

<b>1st Method :</b>

Properties props = new Properties();

InputStream is =

application.getResourceAsStream(

"test.properties");

if (is != null) {

props.load(is);

is.close();

Enumeration keysEnum = Props.propertyNames();

while (keysEnum.hasMoreElements()) {

out.println(keysEnum.nextElement()) ;

}

<b>2nd Method :</b>

Here "com.sap.package" is the package name and "test" is the Properties file name

ResourceBundlebundle = ResourceBundle.getBundle("com.sap.package.test");

for (Enumeration e = bundle.getKeys(); e.hasMoreElements();)

{

String key = (String) e.nextElement();

out.print((String) e.nextElement());

String s = bundle.getString(key);

request.getComponentSession().putValue(key, s);

}

I cannot read the properties file even when I keep in it the WEB-INF folder.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 21, 2006 at 03:57 AM

    Hi,

    Welcome to SDN.

    Did you place the properties file directly in WEB-INF? or WEB-INF/private/classes folder.

    Post your query in the "Java Programming folder" or "Portal Content Development" forum.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.