S
subi
Hi,
I am using property file to get a rate revision date. When I first use
the
getServletConfig().getServletContext().getRealPath("ratecheck.properties"),
i got the non-static method ServletConfig() can not be used in static
context. So I created one more method getPath() and used a member
method got it solved.
But I am still not able to get the RATEREVISION printed (im printing
the RATEREVISION below after some lines of other codings). It displays
nothing even an exception. I have both the the servlet and properties
file in same folder.
Please let me have a solution.
class test extends HttpServlet
{
String getPath()
{
String
propFile=getServletConfig().getServletContext().getRealPath("ratecheck.properties");
return propFile;
}
static String rateFinder()
{
String rate="";
try
{
Properties prop= new Properties();
String propFile=new test().getPath();
File file = new File("ratecheck.properties");
prop.load(new FileInputStream(propFile));
rate=prop.getProperty("rate-revision");
}
catch (Exception e)
{
rate=e.getMessage();
}
return rate;
}
/*
...some codings..
..*/
public final static String RATEREVISION = rateFinder();
}
Thank you,
Subi
I am using property file to get a rate revision date. When I first use
the
getServletConfig().getServletContext().getRealPath("ratecheck.properties"),
i got the non-static method ServletConfig() can not be used in static
context. So I created one more method getPath() and used a member
method got it solved.
But I am still not able to get the RATEREVISION printed (im printing
the RATEREVISION below after some lines of other codings). It displays
nothing even an exception. I have both the the servlet and properties
file in same folder.
Please let me have a solution.
class test extends HttpServlet
{
String getPath()
{
String
propFile=getServletConfig().getServletContext().getRealPath("ratecheck.properties");
return propFile;
}
static String rateFinder()
{
String rate="";
try
{
Properties prop= new Properties();
String propFile=new test().getPath();
File file = new File("ratecheck.properties");
prop.load(new FileInputStream(propFile));
rate=prop.getProperty("rate-revision");
}
catch (Exception e)
{
rate=e.getMessage();
}
return rate;
}
/*
...some codings..
..*/
public final static String RATEREVISION = rateFinder();
}
Thank you,
Subi