Thanks. I don't use get and set methods much. Maybe I should? Right now I usually just call a void method from the constructor of a class and set the member variables in the void method. My classes are really slim and specialized as a result. I do have a lot to learn about programming so I'm not even sure if the way I do this is even considered good or not.
Later when I want the value of the member variable, I use something like this which is how I implemented your code example above to achieve the result in the
servlet:
//This is storing the DOM of the XML file in the servlet context.
//To keep it cached
//When the first user arrives, it will be null and therefore set
if(sc.getAttribute("myDom")==null){
sc.setAttribute("myDom", new TDOMBuilder(sXmlFilePath).document);
sc.setAttribute("fileLM",new TFileLastModified(sXmlFilePath));
}
//lets
test to see if the file has been updated and if so we will rebuild //the DOM.
TFileLastModified fileLM = (TFileLastModified)sc.getAttribute("fileLM");
fLastModifiedCached = fileLM.lMod;
//I don't like calling this everytime, notify - observer - subscriber would //be nice if could be
fLastModifedTest = new TFileLastModified(sXmlFilePath).lMod;
if(fLastModifiedCached != fLastModifedTest){
sc.setAttribute("myDom", new TDOMBuilder(sXmlFilePath).document);
sc.setAttribute("fileLM",new TFileLastModified(sXmlFilePath));
}
//Transform and Print out the page
out.println(new TXMLTransformer(sXSLFilePath,sc.getAttribute("myDom")).htmlString);
Voila, it works. Thanks for all the help everyone over the past week or so. My little XML app is done!
[ January 30, 2006: Message edited by: Stu Higgs ]