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

Discussion in 'Java' started by RC, Jul 7, 2005.

  1. RC

    RC Guest

    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
     
    RC, Jul 7, 2005
    #1
    1. Advertising

  2. 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.
     
    Tor Iver Wilhelmsen, Jul 7, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SAMBA
    Replies:
    2
    Views:
    13,265
    Andy Flowers
    Nov 9, 2004
  2. lordy

    To getenv or not getenv

    lordy, Jul 28, 2006, in forum: Java
    Replies:
    2
    Views:
    4,890
    lordy
    Jul 28, 2006
  3. Replies:
    4
    Views:
    13,356
    Simon Brooke
    Nov 11, 2006
  4. Andrew Thompson

    javax.servlet and javax.servlet.http

    Andrew Thompson, Apr 24, 2007, in forum: Java
    Replies:
    1
    Views:
    711
    newbie_at_tomcat
    Apr 25, 2007
  5. Lew
    Replies:
    1
    Views:
    635
    newbie_at_tomcat
    Apr 25, 2007
Loading...

Share This Page