IS there any other way that i cud write a code in jsp for reading values from a properties file........
Printable View
IS there any other way that i cud write a code in jsp for reading values from a properties file........
a sample property file
-----------------------
myproperty.peroperty1=A
myproperty.peroperty2=B
jsp code
--------
<%@page import="java.io.*,java.util.*%">
<%
Properties pro=new Properties();
FileInputStream fis=new FileInputStream("myproperties.property";
pro.load(fis);
fis.close();
String prop1=pro.getProperty("myproperty.property1");
String prop2=pro.getProperty("myproperty.property2");
%>
Thnks a lot .
Hi Nandini
here is the code,
how i am reading the property file in a jsp page
thanksCode:<%
try {
java.util.Properties p = new java.util.Properties();
p.clear();
p.load(new java.io.FileInputStream("PropFile.property"));
sUser = p.getProperty("user", sUser);
sPassword = p.getProperty("password", sPassword);
if (sPassword == null || sPassword.equals("")) {
sPassword = sUser;
}
} catch (java.io.FileNotFoundException e) {
System.out.println("File not found: " + PropFile.property );
} catch (Exception e) {
System.out.println(e);
}
%>
/\/ :)