Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Is there a getEnv(String string) method in javax.servlet.http package?

Reply
Thread Tools

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

 
 
RC
Guest
Posts: n/a
 
      07-07-2005
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
 
Reply With Quote
 
 
 
 
Tor Iver Wilhelmsen
Guest
Posts: n/a
 
      07-07-2005
RC <> writes:

> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to get a method to always run at the end of anydescendent's initialize method? Xeno Campanoli Ruby 9 02-14-2010 03:49 AM
Is there a method (similar to str() method in R) that can print thedata structure in python? Peng Yu Python 0 09-26-2009 02:32 PM
Is there a method to tell me the name of the method I'm in? Xeno Campanoli Ruby 3 06-11-2009 03:42 AM
method def in method vs method def in block Kyung won Cheon Ruby 0 11-21-2008 08:48 AM
is there a hardware / driver combination out there the lets win2k connect to the network before login?? christiane kewitz Wireless Networking 1 02-13-2005 01:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57