You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Gopa Kumar <go...@ardentsoftware.com> on 2000/08/11 17:19:46 UTC

Accessing Env variables from tomcat servlets

Hi,

Does anybody know how to access env variables from tomcat servlets.  I have
an Apache module that adds a bunch of env vars into
request_rec->subprocess_env.  They are working ok with Perl CGI.  Since I am
now trying to port some of these scripts into servlets, I need to access
these vars from servlets.  I tried setting tomcat.properties
wrapper.env.copyall=true and also ApJServEnvVar but to no avail.
req.getAttributeNames still does not return any of my env vars.
Incidentally, I did see code for handling ApJServEnvVar in mod_jserv.c.  Am
I doing something wrong, or is there another way to access these variables ?

thanks,

-Gopa

Re: newbie queries!

Posted by William Brogden <wb...@bga.com>.

Pratik wrote:
> 
> hi
> 
> i have installed tomcat3.1 & jdk1.3 in Win98
> 
> 1. i get the "out of environment space" error several times when i run the
> autoexec.bat file.

You must increase the Environment space - in a MSDOS window, click the
upper
left corner, access the properties dialog, Memory tab, set Initial
Environment
higher - mine works at 3072.

> the classpath is not being set. what can i do? what does this error mean?
> my autoexec.bat file looks like this -
>     SET PATH=%PATH%;C:\JDK1.3\BIN;C:\TOM\BIN;
>     SET JAXPHOME=C:\Program Files\JavaSoft\Jaxp1.0.1
>     SET CLASSPATH=%JAXPHOME%\JAXP.JAR;%JAXPHOME%\PARSER.JAR
>     SET CLASSPATH=%CLASSPATH%;.;C:\TOM\BIN;C:\TOM\LIB\SERVLET.JAR;
>     SET
> CLASSPATH=%CLASSPATH%;C:\TOM\LIB\WEBSERVER.JAR;C:\TOM\LIB\JASPER.JAR;
>     SET CLASSPATH=%CLASSPATH%;C:\TOM\LIB\ANT.JAR;C:\TOM\LIB\XML.JAR
>     SET TOMCAT_HOME=C:\TOM
>     SET JAVA_HOME=C:\JDK1.3
> 
> 2.some times I get this error while launching tomcat also. i donot get this
> error when i use
> "Just Go - The Tomcat Laucher" advertised in this list but i again get it
> when i try to build
> a servlet using build.bat.
> 
> 3. i am also getting the following error
> - java.lang.NoClassDefFoundError : sun/tools/javac/main at
> org.apache.tools.ant.*

Make sure the tools.jar from the JDK is where tomcat can find it.



-- 
WBB - wbrogden@bga.com  Chief Scientist, LANWrights, Inc.
Java Programmer Certification information and mock exam
at  http://www.lanw.com/java/javacert/

newbie queries!

Posted by Pratik <pr...@starhub.net.sg>.
hi

i have installed tomcat3.1 & jdk1.3 in Win98

1. i get the "out of environment space" error several times when i run the
autoexec.bat file.
the classpath is not being set. what can i do? what does this error mean?
my autoexec.bat file looks like this -
    SET PATH=%PATH%;C:\JDK1.3\BIN;C:\TOM\BIN;
    SET JAXPHOME=C:\Program Files\JavaSoft\Jaxp1.0.1
    SET CLASSPATH=%JAXPHOME%\JAXP.JAR;%JAXPHOME%\PARSER.JAR
    SET CLASSPATH=%CLASSPATH%;.;C:\TOM\BIN;C:\TOM\LIB\SERVLET.JAR;
    SET
CLASSPATH=%CLASSPATH%;C:\TOM\LIB\WEBSERVER.JAR;C:\TOM\LIB\JASPER.JAR;
    SET CLASSPATH=%CLASSPATH%;C:\TOM\LIB\ANT.JAR;C:\TOM\LIB\XML.JAR
    SET TOMCAT_HOME=C:\TOM
    SET JAVA_HOME=C:\JDK1.3

2.some times I get this error while launching tomcat also. i donot get this
error when i use
"Just Go - The Tomcat Laucher" advertised in this list but i again get it
when i try to build
a servlet using build.bat.

3. i am also getting the following error
- java.lang.NoClassDefFoundError : sun/tools/javac/main at
org.apache.tools.ant.*
when i build a servlet using build.bat as mentioned above.
does that mean that after installing tomcat - I need to separately install
ant, to use it?
shouldn't the ant.jar file in TOMCAT_HOME/lib dir serve the purpose?

4. in the build.xml file for the hello world app included with the tomcat
doc
init="init" setting is not being recognized in any of the <target ... > tags
during compilation?
can i just remove it?

similarly the items="*" setting in the <jar> tags under  <target name="dist"
..>
gives a "deprecated.." warning . can i just remove it as well?

this is my first tryst with java/servlets/tomcat etc. any help will be
greatly appreciated!
thank you

pratik





Re: Accessing Env variables from tomcat servlets

Posted by Jim Rudnicki <jd...@pacbell.net>.
The two processes, Tomcat and Apache, are not running in the same
envrironment.  Changing the environment in one does/should not effect the
other.  Even if you could get both as children of the same process, usually
environment's are inherited only at startup.  Because they are not shared,
changes in one would not be reflected in the other.

The Perl scripts can be passed information through the environment because
they are child processes/shells of the parent/server that are created each
time the request is made.

Jim

From: "Gopa Kumar" <go...@ardentsoftware.com>
To: <to...@jakarta.apache.org>
Sent: Friday, August 11, 2000 8:19 AM
Subject: Accessing Env variables from tomcat servlets

> Does anybody know how to access env variables from tomcat servlets.  I
have
> an Apache module that adds a bunch of env vars into
> request_rec->subprocess_env.  They are working ok with Perl CGI.  Since I
am
> now trying to port some of these scripts into servlets, I need to access
> these vars from servlets.  I tried setting tomcat.properties
> wrapper.env.copyall=true and also ApJServEnvVar but to no avail.



Re: Accessing Env variables from tomcat servlets

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Gopa Kumar wrote:

> Hi,
>
> Does anybody know how to access env variables from tomcat servlets.  I have
> an Apache module that adds a bunch of env vars into
> request_rec->subprocess_env.  They are working ok with Perl CGI.  Since I am
> now trying to port some of these scripts into servlets, I need to access
> these vars from servlets.  I tried setting tomcat.properties
> wrapper.env.copyall=true and also ApJServEnvVar but to no avail.
> req.getAttributeNames still does not return any of my env vars.
> Incidentally, I did see code for handling ApJServEnvVar in mod_jserv.c.  Am
> I doing something wrong, or is there another way to access these variables ?
>

Most of the environment variables you are interested in are actually
request
properties on the request object.  For instance, the value of the
PATH_INFO
environment variable corresponds to the request.getPathInfo() method. 
Check out
the API documents on the javax.servlet.http.HttpServletRequest interface
(and
javax.servlet.ServletRequest, which it extends) to see what information
is
available to you.


>
> thanks,
>
> -Gopa

Craig McClanahan