tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allistair Crossley" <Allistair.Cross...@QAS.com>
Subject RE: Flexible way of defining application variables in text format?
Date Tue, 27 Sep 2005 08:53:07 GMT
To make this easier in the presentation tier, you would probably want to make this method a
static member of some class (if using scriplet), or a tag if attempting a non-scripted presentation
tier (recommended). 

Allistair.

> -----Original Message-----
> From: gdilem@libero.it [mailto:gdilem@libero.it]
> Sent: 27 September 2005 09:50
> To: tomcat-user
> Subject: Re:Flexible way of defining application variables in text
> format?
> 
> 
> in web.xml u can set all the constants u want as:
> 
>  <env-entry>
>         <env-entry-name>nameVariavle</env-entry-name>
>         <env-entry-value>valueVariable</env-entry-value>
>         <env-entry-type>java.lang.String or whatelse</env-entry-type>
>     </env-entry>
> 
> and use this for getting them
> public static String  getEnvVar(String name)
>       throws NamingException
>   {
>       String var="";
>       try
>       {
>         Context initCtx = new InitialContext();
>         Context envCtx = (Context) initCtx.lookup( "java:comp/env" );
>         var = (String) envCtx.lookup( name );
>       }
>      catch (NamingException e) {
>       e.printStackTrace();
>     }
>     return var;
>   }
> 
> regards!!
> 
> ---------- Initial Header -----------
> 
> From      : "Seak, Teng-Fong" seak_tengfong@yahoo.com
> To          : "Tomcat Users List" tomcat-user@jakarta.apache.org
> 
> Cc          : 
> Date      : Tue, 27 Sep 2005 10:36:30 +0200
> Subject : Flexible way of defining application variables in 
> text format?
> 
> 
> 
> 
> 
> 
> 
> 
> >     My webapp needs some application string variables for 
> > configuration.  For the moment, I hard-code them as class static 
> > properties and compiled.  But I'd like to know if there's 
> any method to 
> > define such variables in a text file, something like the 
> global.asa in 
> > ASP where we could simply write something like this withing the 
> > application_onstart subroutine:
> > application("myvar") = "my value"
> > 
> >     I like them to be withing text file because if even 
> there's a need 
> > to change config, I'd like to just launch a text editor, 
> edit it and 
> > start again!  I don't want to install Eclipse or other IDE 
> in deployment 
> 
> > server just in case we need to change some parameter and 
> have to compile 
> > everything.  This is very inconvenient, non professional 
> and stupid.  
> > And the client would probably not appreciate this.
> > 
> >     OK, I know I could write a wrapper function to parse 
> that text file 
> > and assign the correct values, but is there a simpler way?  Is the 
> > answer lying in the "web.xml" file?  But its syntax seems quite 
> > complicated that I've no idea what to begin.
> > 
> >     TIA
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> 
-------------------------------------------------------
QAS Ltd.
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT> <FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLACK> 
Disclaimer:  The information contained within this e-mail is confidential and may be privileged.
This email is intended solely for the named recipient only; if you are not authorised you
must not disclose, copy, distribute, or retain this message or any part of it. If you have
received this message in error please contact the sender at once so that we may take the appropriate
action and avoid troubling you further.  Any views expressed in this message are those of
the individual sender.  QAS Limited has the right lawfully to record, monitor and inspect
messages between its employees and any third party.  Your messages shall be subject to such
lawful supervision as QAS Limited deems to be necessary in order to protect its information,
its interests and its reputation.  

Whilst all efforts are made to safeguard Inbound and Outbound emails, QAS Limited cannot guarantee
that attachments are virus free or compatible with your systems and does not accept any liability
in respect of viruses or computer problems experienced.
</FONT>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message