I'm trying to return a DOM and store it in the ServletContext via
sc.setAttribute("myDom", new TDOMBuilder(sXmlFilePath));
no problem so far, but I am not sure whether this is even allowed or not?
Then, I am trying to send that DOM stored in myDom to a method that will use the DOM in an XSLT transform like this:
new TXMLTransformer(sXSLFilePath, sc.getAttribute("myDom"))
My question is how do I get the constructor in TXMLTransformer to see sc.getAttribute("myDom") as a Document type without a ClassCastException?
I have tried to set the constructor arg to Document, but then compiler complains that TXMLTransformer is looking for an Object type arg not supplied. If changing to Object in the TXMLTransformer arg, then later in TXMLTransformer how do I get that object to be of Document Type without ClassCastException?
I believe I have solved the problem by using this:
sc.setAttribute("myDom", new TDOMBuilder(sXmlFilePath).document);
prior to that I think I was just returning the Object and not the reference to the member variable in the object.
Now I am wondering if I will be able to access myDom via sc.getAttribute("myDom") from any servlet, and is it now stored similarto a session object?
Thanks. [ January 30, 2006: Message edited by: Stu Higgs ]
The get and setAttribute methods of ServletContext work the same way they do for the session or request scopes (except for their scope, of course). You're just binding an object to a map and then retrieving it with a key.