• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a propeties file from a Java Client  RSS feed

 
Sri Ram
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a web application in which I have a properties file under WEB-INF/classes folder

I am able to access this properties file from a Servlet using servletContext.getResourceAsStream but I also need access to this properties file from a Java Client .. this Java Client is triggered by Quartz .. any idea?

Your help is highly apprecited!
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I bet you're going to have to make a servlet that does nothing but read the file and dump it to the response, then make the client call the servlet with HttpURLConnection or the Apache HTTPClient or something like that.
 
Don Morgan
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the java client, depending upon the details of your system, what the properties are for, etc, I would actually be tempted to directly access the properties file through the file system instead of writing a servlet which accesses it for you (using the servlet to return properties sounds like overkill to me. Also, using the servlet introduces a dependency between the java client and the servlet/servlet container. Is your java client already dependent on the servlet/servlet container?).

If you do access the properties file through the file system, you do not need to hard code the location of the properties file into your java client. Instead, you can have it passed in either as a command line argument or even as a property itself, and, then within the java client, use that to the find the actual properties file you want to read from. Even if you do use a servlet, you will need to pass in the URL of the servlet into your program, so some work will be required in making sure this string is correct as you move from say your development environment to QA to User Acceptance and ultimately into production.

Also, if you need these properties in multiple locations (both the servlet and the java client), perhaps there is a better place for them which is more easily accessible by both the servlets and any standalone java programs.

[ January 05, 2006: Message edited by: Don Morgan ]

[ January 05, 2006: Message edited by: Don Morgan ]
[ January 05, 2006: Message edited by: Don Morgan ]
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another approach is to place the properties file in the root directory of the web app. I'm not saying that this is the best thing to do, but until we know more about the client it's difficult to suggest the best solution.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!