Re: How can I determine if user is running locally?

Zerbe John W <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
This is what we do:
We require that there be NO changes to a given ".ear" file from one envirnment to the next.
We set a '-DConfig.env=xxx' on the jvm command line, where xxx = 'dev', 'test', 'qa', or 'prod'.
Our developers then load Properties files appropriate to the environment they are running in.
If you bundle your properties files in your WEB-INF/classes directory such as:
WEB-INF/classes/props/test/appenv.properties
WEB-INF/classes/props/qa/appenv.properties
WEB-INF/classes/props/prod/appenv.properties

you can load the appropriate properties via something like:

Properties prop = new(Properties);
String env = System.getProperty("Config.env");
/* build "file name" for properties file */
String filename = "props/" + env + "/appenv.properties";
/* use the current web application's class loader to locate and open the properties file */
InputStream propStream = Thread.currentThread().getContextClassloader().getSystemReasourceAsStream(filename); 
prop.load(propStream);
propStream.close();


(add exception handling as appropriate)

John Zerbe

> -----Original Message-----
> From: Jeremy W. Redmond [mailto:[email protected]]
> Sent: Monday, March 31, 2003 10:00 AM
> To: [email protected]
> Subject: How can I determine if user is running locally?
>
>
> Hello -
>    When writing the code for our system, developers try to
> write the code in a way that will involve the least amount of
> tweaking when deploying from local machine, to production.  I
> was wondering if it is possible to determine whether or not
> the user is running locally (possibly using the HOSTS file in
> Windows) or not.
>
>
> Since the applications may be distributed to many different
> locations, I cannot simply check the IP address and attempt
> to match the first few digits since these may be different on
> everyone's machine.
> (unfortunately this is how I am currently doing it...)
>
> If worse comes to worse, I could REQUIRE the user to use
> "localhost:7001"
> when running locally, but I was wondering if there is a more
> clever way to do this.  All I could come up with is possibly
> reading the HOSTS file.
>
> Any feedback woould be appreciated.
>
> Jeremy
>
> ______________________________________________________________
> _____________
> To unsubscribe, send email to [email protected] and
> include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
> http://java.sun.com/products/servlet/external-> resources.html
>
> LISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html



DISCLAIMER:
The information contained in this e-mail may be confidential and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorized. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator.

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.