You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Maxim Veksler <ma...@gmail.com> on 2008/04/02 17:28:51 UTC

Command line parameters inside webapps ?

Hello everyone,

Can I read from my webapp a command line parameters passed to tomcat
when it's loaded ?
Something of the "-Dsomeparameter=somevalue", alternatively can I get
access to environment variables passed to tomcat on it's
initialization from my webapp ?

What I'm trying to do is allow simple switch that can be passed to my
webapp that would instruct it whether it is running passive or active.



I've been googling for this and couldn't find any references to this.


Thank you,
Maxim.

-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Command line parameters inside webapps ?

Posted by Maxim Veksler <ma...@gmail.com>.
On Wed, Apr 2, 2008 at 6:37 PM, Caldarale, Charles R
<Ch...@unisys.com> wrote:
> > From: hq4ever@gmail.com [mailto:hq4ever@gmail.com] On Behalf
>  > Of Maxim Veksler
>  > Subject: Command line parameters inside webapps ?
>
> >
>  > Something of the "-Dsomeparameter=somevalue"
>
>  Any system property (a -D setting) can be read by any Java method,
>  unless not prohibited by security settings (extremely rare); use
>  System.getProperty() to do so.  If you want to access environment
>  variables, use System.getenv().
>

Wonderful, Thank you very much Chuck.


>  This is basic Java, nothing to do with Tomcat.
>
>   - Chuck
>
>
>  THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>  MATERIAL and is thus for use only by the intended recipient. If you
>  received this in error, please contact the sender and delete the e-mail
>  and its attachments from all computers.
>
>
>
>  ---------------------------------------------------------------------
>  To start a new topic, e-mail: users@tomcat.apache.org
>  To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>  For additional commands, e-mail: users-help@tomcat.apache.org
>
>



-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Command line parameters inside webapps ?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: hq4ever@gmail.com [mailto:hq4ever@gmail.com] On Behalf 
> Of Maxim Veksler
> Subject: Command line parameters inside webapps ?
> 
> Something of the "-Dsomeparameter=somevalue"

Any system property (a -D setting) can be read by any Java method,
unless not prohibited by security settings (extremely rare); use
System.getProperty() to do so.  If you want to access environment
variables, use System.getenv().

This is basic Java, nothing to do with Tomcat.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Command line parameters inside webapps ?

Posted by Maxim Veksler <ma...@gmail.com>.
On Wed, Apr 2, 2008 at 6:36 PM, David kerber <dc...@verizon.net> wrote:
> Yes.  You can use System.getProperty( "myPropertyName", "defaultValue" ) to
> retrieve system parameters set on startup with
> -DmyPropertyName="myPropertyValue"
>
>

Great thank you.

>
>  Maxim Veksler wrote:
>
> > Hello everyone,
> >
> > Can I read from my webapp a command line parameters passed to tomcat
> > when it's loaded ?
> > Something of the "-Dsomeparameter=somevalue", alternatively can I get
> > access to environment variables passed to tomcat on it's
> > initialization from my webapp ?
> >
> > What I'm trying to do is allow simple switch that can be passed to my
> > webapp that would instruct it whether it is running passive or active.
> >
> >
> >
> > I've been googling for this and couldn't find any references to this.
> >
> >
> > Thank you,
> > Maxim.
> >




-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Command line parameters inside webapps ?

Posted by David kerber <dc...@verizon.net>.
Yes.  You can use System.getProperty( "myPropertyName", "defaultValue" ) 
to retrieve system parameters set on startup with 
-DmyPropertyName="myPropertyValue"


Maxim Veksler wrote:
> Hello everyone,
>
> Can I read from my webapp a command line parameters passed to tomcat
> when it's loaded ?
> Something of the "-Dsomeparameter=somevalue", alternatively can I get
> access to environment variables passed to tomcat on it's
> initialization from my webapp ?
>
> What I'm trying to do is allow simple switch that can be passed to my
> webapp that would instruct it whether it is running passive or active.
>
>
>
> I've been googling for this and couldn't find any references to this.
>
>
> Thank you,
> Maxim.
>
>   



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org