Is there a getEnv(String string) method in javax.servlet.http package?

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
 
T

Tor Iver Wilhelmsen

RC said:
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.

No, you get the ServletContext and ServerConfig objects.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top