<%! FxDataModel FxDataModel = null;
public void jspInit() {
Properties fxProp = new Properties();
ServletContext ctx = getServletContext();
String path = ctx.getRealPath("/WEB-INF/fxRates.csv");
fxProp.getProperty(path);
try{
FileInputStream fis = new FileInputStream( ctx.getRealPath( ctx.getInitParameter( FxDataModel.FX_PRP_FILE_NAME ) ) );
// Now that you have fis you can load properties.
fxProp.load( fis );
// Now, you are done with fis so close it
fis.close();
}catch ( IOException e ) {}
FxDataModel = new FxDataModel( fxProp );
}
%>
Looking at my code in NetBeans, everything seems fine. However, when I run it i get an HTTP Status 500 error. When I asked my professor about how to fix it he told me,
“Apparently, fxRates.csv was not since you failed to expand the file
name to an absolute path with getRealPath and re-insert it into the
Properties object fxProp.”
I’m not entirely sure what other code from my project I have to add, but I had a feeling that the error resided in this section. What am I doing wrong?
the way Properties api works is similar to map
use put to add or update a property and get to retrieve. Not sure what you wanted to do though