Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
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

Report this thread to moderator Post Follow-up to this message
Old Post
Brian
09-21-04 02:03 AM


Re: JSP Help - Platform indepdent way to find a properties file from a bean?
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


Report this thread to moderator Post Follow-up to this message
Old Post
kaeli
09-21-04 08:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:14 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.