Home > Archive > Java Help > September 2004 > JSP Help - Platform indepdent way to find a properties file from a bean?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
JSP Help - Platform indepdent way to find a properties file from a bean?
|
|
|
| I am new to JSP and Beans. I am writing a JSP page using JavaBeans.
I want to have a .props file, which contains properties for my
application (like location of files, settings, whatever).
My question is, where do I put my .props file and how can I get my
bean to find it?
I was thinking of using something like passing the servelet context,
similiar to this (if I had a servlet, but I am using a bean)
ServletContext sContext = getServletContext();
String value = null;
value = getInitParameter("properties");
String propsFile = sContext.getRealPath(".") + "\\"+ value;
The "getRealPath" will work no matter where my Tomcat server is
installed. That is my goal, to be able to deploy the application on
windows, or unix, or whatever, and not have to manually go and specify
where my props file is. I just want my app to derive where it is
located and then just look for a particular filename, like
"properties" or whatever.
Thanks for any suggestions
| |
|
| In article <961d6f35.0409201305.1f0a886f@posting.google.com>, lucid1
@mediaone.net enlightened us with...
> I was thinking of using something like passing the servelet context,
> similiar to this (if I had a servlet, but I am using a bean)
>
Beans can have access to servletContext.
You just have to explicitly set it up with getter/setter and pass it in from
the JSP page.
I pass in pageContext this way to my beans.
Here's an even easier way:
http://www.jguru.com/faq/view.jsp?EID=225150
--
--
~kaeli~
Press any key to continue or any other key to quit
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
|
|
|
|
|