instead of using ip address, I am using host name something like the following:
if
(java.net.InetAddress.getLocalHost().getHostName().equals("yourservername.yourdomain.com"))
get the different properties or xml files;
if your production server using SSL and local server is not, you can using something
like:
if (request.getHeader("Referer").startsWith("https://"))
using different properties or xml files;
Hope this will help.
-Kevin
-----Original Message-----
From: Zerbe John W [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 01, 2003 1:21 PM
To: [EMAIL PROTECTED]
Subject: Re: How can I determine if user is running locally?
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
=======
Notice: This e-mail message, together with any attachments, contains
information of Symyx Technologies, Inc. that may be confidential,
proprietary, copyrighted, privileged and/or protected work product,
and is meant solely for the intended recipient. If you are not the
intended recipient, and have received this message in error, please
contact the sender immediately, permanently delete the original and
any copies of this email and any attachments thereto.
___________________________________________________________________________
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