Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageIn 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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.