R
RC
We all known there are a lot of
CGI Environment variables in httpd.
For example:
SERVER_NAME
SERVER_PORT
QUERY_STRING
....
etc.
To get these httpd environment variables.
If you write PERL CGI script, then you will do
$PRIMARY_DB_SERVER = $ENV{'PRIMARY_DB_SERVER'};
print "Primary database server is $PRIMARY_DB_SERVER<br>\n";
If you write PHP, then you will do
$primaryServer = $_SERVER["PRIMARY_DB_SERVER"];
print "Seconday database server is $secondaryServer<br>\n";
Now I want to write in a Java Servlet or JSP.
How can I do that? I can NOT find
request.getEnv(String string) method in
javax.servlet.http package.
There are a lot of getXXXX() methods like
request.getServerName();
request.getServerPort();
.... etc.
request.getParameter("string");
won't get the environment variables.
It only get variable from HTML form.
Does anyone out there know how can I do
getEnv(string) in Java servlet/JSP?
Thank you very much in advance!
P.S. somebody wonder where is that
PRIMARY_DB_SERVER environment variable
comes from, there is no such environment
variable in httpd. Well, if you look at
O'Reilly book Apache The Definitive Guide
by Ben Laurie and Peter Laurie at Chapter
4: Common Gateway Interface(CGI). You will
find
SetEnv and PassEnv, you can
SetEnv VariableName VariableValue in
http.conf file
CGI Environment variables in httpd.
For example:
SERVER_NAME
SERVER_PORT
QUERY_STRING
....
etc.
To get these httpd environment variables.
If you write PERL CGI script, then you will do
$PRIMARY_DB_SERVER = $ENV{'PRIMARY_DB_SERVER'};
print "Primary database server is $PRIMARY_DB_SERVER<br>\n";
If you write PHP, then you will do
$primaryServer = $_SERVER["PRIMARY_DB_SERVER"];
print "Seconday database server is $secondaryServer<br>\n";
Now I want to write in a Java Servlet or JSP.
How can I do that? I can NOT find
request.getEnv(String string) method in
javax.servlet.http package.
There are a lot of getXXXX() methods like
request.getServerName();
request.getServerPort();
.... etc.
request.getParameter("string");
won't get the environment variables.
It only get variable from HTML form.
Does anyone out there know how can I do
getEnv(string) in Java servlet/JSP?
Thank you very much in advance!
P.S. somebody wonder where is that
PRIMARY_DB_SERVER environment variable
comes from, there is no such environment
variable in httpd. Well, if you look at
O'Reilly book Apache The Definitive Guide
by Ben Laurie and Peter Laurie at Chapter
4: Common Gateway Interface(CGI). You will
find
SetEnv and PassEnv, you can
SetEnv VariableName VariableValue in
http.conf file