Reading Property files...related to servlets
Hi All, My application is a servlet and it uses another application that tries to read a property file. Now the problem is that this application was never designed to work along with a servlet and does not read its property file using a method like getServletContext().getResourceAsStream(/foo.html); Now the question that I have for you bright folks out there is how am I supposed to go about feeding this application its property file:) Thanks, -Sumit -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 9:07 AM To: Tomcat Users List Subject: RE: Relative paths in servlets? Hi, Did you try getServletContext().getResourceAsStream(/foo.html); ? Yoav Shapira Millennium ChemInformatics -Original Message- From: Øyvind Hvamstad [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:36 AM To: [EMAIL PROTECTED] Subject: Relative paths in servlets? Hi, could anyone tell me how to access files using relative paths from a servlet? Say, if servlet is mapped to /bar and the file foo.html is in the webapps top dir. How do I access the foo.html file from the servlet. I tried ../foo.html, /foo.html and even getServletContext().getRealPath(/bar)+/../foo.html but none works. Any pointers? -- Øyvind Hvamstad -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Reading Property files...related to servlets
Hi, That depends entirely on the application. Its documentation should indicate how it can be configured to read the file. Chances are for one of the following: - The app has some configuration file where you can specify the file path - The app can take a runtime CLI parameter, e.g. -DappConfigFile=... that you can use - The app uses Classloader's getResource() calls, in which case you just need to put the file in the proper place on the classpath for the app to find it. If the app isn't well documented, do you have its source code? Or do you have support for the app that can tell you this? Yoav Shapira Millennium ChemInformatics -Original Message- From: Shrotriya, Sumit [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 9:35 AM To: 'Tomcat Users List' Subject: Reading Property files...related to servlets Hi All, My application is a servlet and it uses another application that tries to read a property file. Now the problem is that this application was never designed to work along with a servlet and does not read its property file using a method like getServletContext().getResourceAsStream(/foo.html); Now the question that I have for you bright folks out there is how am I supposed to go about feeding this application its property file:) Thanks, -Sumit -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 9:07 AM To: Tomcat Users List Subject: RE: Relative paths in servlets? Hi, Did you try getServletContext().getResourceAsStream(/foo.html); ? Yoav Shapira Millennium ChemInformatics -Original Message- From: Øyvind Hvamstad [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:36 AM To: [EMAIL PROTECTED] Subject: Relative paths in servlets? Hi, could anyone tell me how to access files using relative paths from a servlet? Say, if servlet is mapped to /bar and the file foo.html is in the webapps top dir. How do I access the foo.html file from the servlet. I tried ../foo.html, /foo.html and even getServletContext().getRealPath(/bar)+/../foo.html but none works. Any pointers? -- Øyvind Hvamstad -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Reading Property files...related to servlets
This is a good idead Wendy but I can't change their code.. Sumit wrote: Now the question that I have for you bright folks out there is how am I supposed to go about feeding this application its property file:) Will this do? ClassLoader cl = YourClassName.class.getClassLoader(); Properties props = new Properties(); props.load( cl.getResourceAsStream( some.properties ) ) ; -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University PA Information Resources Management
RE: Reading Property files...related to servlets
Hi Yoav, Well of all that I know of this application is that it reads a file from a directory structure Something like com/apps/Application/sample.prop and the application is also in the same package whereas my application resides in the package com/apps/MyApp/MyService Now, this very same setup works great when I use Tomcat 3.3 but with Tomcat4.1.18 the application fails to read its property file. Any Ideas.. -Sumit Hi, That depends entirely on the application. Its documentation should indicate how it can be configured to read the file. Chances are for one of the following: - The app has some configuration file where you can specify the file path - The app can take a runtime CLI parameter, e.g. -DappConfigFile=... that you can use - The app uses Classloader's getResource() calls, in which case you just need to put the file in the proper place on the classpath for the app to find it. If the app isn't well documented, do you have its source code? Or do you have support for the app that can tell you this? Yoav Shapira Millennium ChemInformatics -Original Message- From: Shrotriya, Sumit [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 9:35 AM To: 'Tomcat Users List' Subject: Reading Property files...related to servlets Hi All, My application is a servlet and it uses another application that tries to read a property file. Now the problem is that this application was never designed to work along with a servlet and does not read its property file using a method like getServletContext().getResourceAsStream(/foo.html); Now the question that I have for you bright folks out there is how am I supposed to go about feeding this application its property file:) Thanks, -Sumit -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 9:07 AM To: Tomcat Users List Subject: RE: Relative paths in servlets? Hi, Did you try getServletContext().getResourceAsStream(/foo.html); ? Yoav Shapira Millennium ChemInformatics -Original Message- From: Øyvind Hvamstad [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:36 AM To: [EMAIL PROTECTED] Subject: Relative paths in servlets? Hi, could anyone tell me how to access files using relative paths from a servlet? Say, if servlet is mapped to /bar and the file foo.html is in the webapps top dir. How do I access the foo.html file from the servlet. I tried ../foo.html, /foo.html and even getServletContext().getRealPath(/bar)+/../foo.html but none works. Any pointers? -- Øyvind Hvamstad -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Reading Property files...related to servlets
Hi, Is that all the app documentation says? Do you know the name of the class that tries to read sample.prop and what argument it passes into the classloader getResource() call? If you put sample.prop in the same directory as the classes in the com.apps.Application package, it should work. Yoav Shapira Millennium ChemInformatics -Original Message- From: Shrotriya, Sumit [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 10:00 AM To: 'Tomcat Users List' Subject: RE: Reading Property files...related to servlets Hi Yoav, Well of all that I know of this application is that it reads a file from a directory structure Something like com/apps/Application/sample.prop and the application is also in the same package whereas my application resides in the package com/apps/MyApp/MyService Now, this very same setup works great when I use Tomcat 3.3 but with Tomcat4.1.18 the application fails to read its property file. Any Ideas.. -Sumit Hi, That depends entirely on the application. Its documentation should indicate how it can be configured to read the file. Chances are for one of the following: - The app has some configuration file where you can specify the file path - The app can take a runtime CLI parameter, e.g. -DappConfigFile=... that you can use - The app uses Classloader's getResource() calls, in which case you just need to put the file in the proper place on the classpath for the app to find it. If the app isn't well documented, do you have its source code? Or do you have support for the app that can tell you this? Yoav Shapira Millennium ChemInformatics -Original Message- From: Shrotriya, Sumit [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 9:35 AM To: 'Tomcat Users List' Subject: Reading Property files...related to servlets Hi All, My application is a servlet and it uses another application that tries to read a property file. Now the problem is that this application was never designed to work along with a servlet and does not read its property file using a method like getServletContext().getResourceAsStream(/foo.html); Now the question that I have for you bright folks out there is how am I supposed to go about feeding this application its property file:) Thanks, -Sumit -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 9:07 AM To: Tomcat Users List Subject: RE: Relative paths in servlets? Hi, Did you try getServletContext().getResourceAsStream(/foo.html); ? Yoav Shapira Millennium ChemInformatics -Original Message- From: Øyvind Hvamstad [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:36 AM To: [EMAIL PROTECTED] Subject: Relative paths in servlets? Hi, could anyone tell me how to access files using relative paths from a servlet? Say, if servlet is mapped to /bar and the file foo.html is in the webapps top dir. How do I access the foo.html file from the servlet. I tried ../foo.html, /foo.html and even getServletContext().getRealPath(/bar)+/../foo.html but none works. Any pointers? -- Øyvind Hvamstad -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Reading Property files...related to servlets
Hi Sumit, you could read the properties file yourself as InputStream, create a temp file from this and pass this temp file or the real path to the temp file to the other app. It shouldn't be bad for performance, if only done once. But you can't write to it any more, because it's temp. Andreas On 6 Jan 2003 at 8:35, Shrotriya, Sumit wrote: Hi All, My application is a servlet and it uses another application that tries to read a property file. Now the problem is that this application was never designed to work along with a servlet and does not read its property file using a method like getServletContext().getResourceAsStream(/foo.html); Now the question that I have for you bright folks out there is how am I supposed to go about feeding this application its property file:) Thanks, -Sumit -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 9:07 AM To: Tomcat Users List Subject: RE: Relative paths in servlets? Hi, Did you try getServletContext().getResourceAsStream(/foo.html); ? Yoav Shapira Millennium ChemInformatics -Original Message- From: Øyvind Hvamstad [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:36 AM To: [EMAIL PROTECTED] Subject: Relative paths in servlets? Hi, could anyone tell me how to access files using relative paths from a servlet? Say, if servlet is mapped to /bar and the file foo.html is in the webapps top dir. How do I access the foo.html file from the servlet. I tried ../foo.html, /foo.html and even getServletContext().getRealPath(/bar)+/../foo.html but none works. Any pointers? -- Øyvind Hvamstad -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Reading Property files...related to servlets
Thanks Yoav. that helped...I was running after the wrong horse:) Regards, -Sumit -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 10:31 AM To: Shrotriya, Sumit Subject: RE: Reading Property files...related to servlets Hi, It looks like the configuration file is read OK. The problem is with the JNDI context name binding. The JNDI implementation in tomcat 4 is completely different from tomcat 3. Without a more thorough knowledge of this 3rd party application, no one will be able to help you ;( If this app has any support, I suggest you contact them. Thanks, Yoav Shapira Millennium ChemInformatics -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]