When I reference to a DTD file in my code, I don’t know how to reference to it within my project’s folder. e.g : If my project’s name is Moo, I’d want to refernce the DTD at /Moo/WEB-INF/courses.dtd.
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = null;
try { trans = transfac.newTransformer(); }
catch (TransformerConfigurationException e) { }
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "/Moo/WEB-INF/courses.dtd");
But it doesn’t find it. How can I reference it?
I was offered a solution using getRealPath problem is since my project will be read as a .war file this is not good. What should I do?
First of all, do not include “Moo”. For servlet root is one level up from WEB-INF.
Not sure that OutputKeys.DOCTYPE_SYSTEM wants relative path. Absolute path is: