RE: Embedding XML documents as children of the context-param element
>Is there any reason why you couldn't store your *.xml file in WEB-INF/ No. There is no problem with doing this and it's probably the method I'll use. Thanks everyone for all the comments. Robert Segal Tools Developer CryptoLogic Inc. 55 St. Clair Ave W., 3rd Floor Toronto, Ontario Canada M4V 2Y7 tel. + 1.416.545.1455 x5896 fax. + 1.416.545.1454 This message, including any attachments, is confidential and/or privileged and contains information intended only for the person(s) named above. Any other distribution, copying or disclosure is strictly prohibited. If you are not the intended recipient or have received this message in error, please notify us immediately by reply email and permanently delete the original transmission from all of your systems and hard drives, including any attachments, without making a copy. -Original Message- From: Brian Munroe [mailto:[EMAIL PROTECTED] Sent: Thursday, August 16, 2007 5:52 PM To: Tomcat Users List Subject: Re: Embedding XML documents as children of the context-param element On 8/16/07, Robert Segal <[EMAIL PROTECTED]> wrote: > So as an alternative I know the second method will work but was curious > if anyone has tried the first method. > I doubt the 1st method is valid, since you are basically inventing new deployment descriptor elements, and I know for sure that Eclipse would go crazy with error messages. In the 2nd method you are basically serializing the XML into a string.. I suppose that is Ok, but I think you have to have also have an java.lang.String element to consider web.xml well formed. Is there any reason why you couldn't store your *.xml file in WEB-INF/ and call it with something like: ServletContext sc = getServletConfig().getServletContext(); String myXMLFIlePath = sc.getRealPath("/WEB-INF/myXMLFIle.xml"); ... Document document = parser.parse(new File(myXMLFilePath)); -- brian - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Embedding XML documents as children of the context-param element
On 8/16/07, Caldarale, Charles R <[EMAIL PROTECTED]> wrote: > > The ServletContext.getRealPath() call will fail if the webapp is in an > unexpanded .war or running on a platform without a normal file system > (e.g., a mobile phone). Better to use > ServletContext.getResourceAsStream(), which will function properly in > all cases. > Ok, good to know. I am fixing my code as we speak. thanks! -- brian - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Embedding XML documents as children of the context-param element
> From: Brian Munroe [mailto:[EMAIL PROTECTED] > Subject: Re: Embedding XML documents as children of the > context-param element > > ServletContext sc = getServletConfig().getServletContext(); > String myXMLFIlePath = sc.getRealPath("/WEB-INF/myXMLFIle.xml"); The ServletContext.getRealPath() call will fail if the webapp is in an unexpanded .war or running on a platform without a normal file system (e.g., a mobile phone). Better to use ServletContext.getResourceAsStream(), which will function properly in all cases. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Embedding XML documents as children of the context-param element
On 8/16/07, Robert Segal <[EMAIL PROTECTED]> wrote: > So as an alternative I know the second method will work but was curious > if anyone has tried the first method. > I doubt the 1st method is valid, since you are basically inventing new deployment descriptor elements, and I know for sure that Eclipse would go crazy with error messages. In the 2nd method you are basically serializing the XML into a string.. I suppose that is Ok, but I think you have to have also have an java.lang.String element to consider web.xml well formed. Is there any reason why you couldn't store your *.xml file in WEB-INF/ and call it with something like: ServletContext sc = getServletConfig().getServletContext(); String myXMLFIlePath = sc.getRealPath("/WEB-INF/myXMLFIle.xml"); ... Document document = parser.parse(new File(myXMLFilePath)); -- brian - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Embedding XML documents as children of the context-param element
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Robert, Robert Segal wrote: > I am curious about a certain possibility to embed XML as a child of a > context-param value in a servlets web.xml file. Here is what I a > looking for... > > > ContextParam1 > > A happy element > > I don't think you can do this, as the DTD and/or schema for the webapp deployment descriptor says you can't. Your CDATA solution is the one you're looking for. Better yet, use to pass a filename to your code, and then read a pristine XML file instead of hacking one into the deployment descriptor. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGxMXb9CaO5/Lv0PARAohfAKCmbKE/FbbkfjIFwIfX2ur5WA1mXQCeMSxT 6iuiiR2AqlqypC9ba7qR5pg= =r6fh -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Embedding XML documents as children of the context-param element
Hi everyone, I am curious about a certain possibility to embed XML as a child of a context-param value in a servlets web.xml file. Here is what I a looking for... ContextParam1 A happy element This doesn't seem to work correctly however I have found using CDATA tags this does work properly... ContextParam1 So as an alternative I know the second method will work but was curious if anyone has tried the first method. Robert Segal Tools Developer CryptoLogic Inc. 55 St. Clair Ave W., 3rd Floor Toronto, Ontario Canada M4V 2Y7 tel. + 1.416.545.1455 x5896 fax. + 1.416.545.1454 This message, including any attachments, is confidential and/or privileged and contains information intended only for the person(s) named above. Any other distribution, copying or disclosure is strictly prohibited. If you are not the intended recipient or have received this message in error, please notify us immediately by reply email and permanently delete the original transmission from all of your systems and hard drives, including any attachments, without making a copy.