global variables inside a Tomcat JSP-Servlet app.

2005-01-03 Thread Ben Bookey

Dear List,

I hope someone can give some hints to a none java/TC -specialist.

We have a jsp-servlet app, which has some important app variables inside
the web.xml. Because the validation for these parameters is quite complex
we have a single public class with public static setters and getters
available to the all servlets and jsp pages within the application.
We use a context listener to read the parameters, so we can initalise this
public object reading the web.xml

This works fine but  I was wondering if there is a better way of doing this
?  Would appreciate any
comment. We are using TC 4.0 and 5.0

regards,

Ben


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Global Variables

2003-12-05 Thread Duncan
Cool.

Thanks for the replies all.

Cheers
- Duncan

Ilari Kontinen wrote:

  -Original Message-
  From: Duncan [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, December 03, 2003 11:50 AM
  To: Tomcat Users List
  Subject: Re: Global Variables
 
 
  Thanks for the replies, but what do I define servletContext as?
 

 An easy way to get the ServletContext from JSP-page is to use the
 Servlet-method getServletContext(). So for getting the context
 parameter, add the following code-snipped:

 % String param = getServletContext().getInitParameter(param); %

 And for then on, you can reference it e.g. by:

 %= param %

  Many thanks
  Duncan
 
  Jardin Xavier wrote:
 
   use
  
   context-param
param-nameparam/param-name
   param-valuevalue/param-value
   /context-param
  
   in the web.xml
  
   and String param = servletContext.getInitParameter(param);
  
   in the JSP.
  
   - Original Message -
   From: Duncan [EMAIL PROTECTED]
   To: Tomcat User List [EMAIL PROTECTED]
   Sent: Wednesday, December 03, 2003 5:08 PM
   Subject: Global Variables
  
Is there a way to set global variables in the web.xml which can be read
by any JSP page?
   
Cheers,
-Duncan

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Global Variables

2003-12-03 Thread Duncan
Is there a way to set global variables in the web.xml which can be read
by any JSP page?

Cheers,
-Duncan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Global Variables

2003-12-03 Thread Jardin Xavier
use

context-param
 param-nameparam/param-name
param-valuevalue/param-value
/context-param

in the web.xml

and String param = servletContext.getInitParameter(param);

in the JSP.


- Original Message - 
From: Duncan [EMAIL PROTECTED]
To: Tomcat User List [EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 5:08 PM
Subject: Global Variables


 Is there a way to set global variables in the web.xml which can be read
 by any JSP page?
 
 Cheers,
 -Duncan
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Global Variables

2003-12-03 Thread Shapira, Yoav

Howdy,
Yeah, context-param parameters are available to all resources within
the context (servlets, JSPs, filters, listeners, etc) for the lifetime
of the application.

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Duncan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 11:08 AM
To: Tomcat User List
Subject: Global Variables

Is there a way to set global variables in the web.xml which can be read
by any JSP page?

Cheers,
-Duncan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Global Variables

2003-12-03 Thread Duncan
Thanks for the replies, but what do I define servletContext as?

Many thanks
Duncan

Jardin Xavier wrote:

 use

 context-param
  param-nameparam/param-name
 param-valuevalue/param-value
 /context-param

 in the web.xml

 and String param = servletContext.getInitParameter(param);

 in the JSP.

 - Original Message -
 From: Duncan [EMAIL PROTECTED]
 To: Tomcat User List [EMAIL PROTECTED]
 Sent: Wednesday, December 03, 2003 5:08 PM
 Subject: Global Variables

  Is there a way to set global variables in the web.xml which can be read
  by any JSP page?
 
  Cheers,
  -Duncan
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Global Variables

2003-12-03 Thread Shapira, Yoav

Howdy,
Are you serious? ;)  You might want to buy a servlets book or go through
a tutorial, this is a very basic concept.

You don't define a servlet context, the server creates one for you.  You
define context parameters in your deployment descriptor, the web.xml
file.

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Duncan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 11:50 AM
To: Tomcat Users List
Subject: Re: Global Variables

Thanks for the replies, but what do I define servletContext as?

Many thanks
Duncan

Jardin Xavier wrote:

 use

 context-param
  param-nameparam/param-name
 param-valuevalue/param-value
 /context-param

 in the web.xml

 and String param = servletContext.getInitParameter(param);

 in the JSP.

 - Original Message -
 From: Duncan [EMAIL PROTECTED]
 To: Tomcat User List [EMAIL PROTECTED]
 Sent: Wednesday, December 03, 2003 5:08 PM
 Subject: Global Variables

  Is there a way to set global variables in the web.xml which can be
read
  by any JSP page?
 
  Cheers,
  -Duncan
 
 
 
-
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail:
[EMAIL PROTECTED]
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Global Variables

2003-12-03 Thread Ben Souther
Here is is added to the default web.xml file that shipps in the 
TOMCAT_HOME/webapps/ROOT/WEB-INF/web.xml file




?xml version=1.0 encoding=ISO-8859-1?

!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
http://java.sun.com/dtd/web-app_2_3.dtd;

web-app
  display-nameWelcome to Tomcat/display-name
  description
 Welcome to Tomcat
  /description


context-param
 param-nameparam/param-name
param-valuevalue/param-value
/context-param


/web-app















On Wednesday 03 December 2003 11:50 am, Duncan wrote:
 Thanks for the replies, but what do I define servletContext as?

 Many thanks
 Duncan

 Jardin Xavier wrote:
  use
 
  context-param
   param-nameparam/param-name
  param-valuevalue/param-value
  /context-param
 
  in the web.xml
 
  and String param = servletContext.getInitParameter(param);
 
  in the JSP.
 
  - Original Message -
  From: Duncan [EMAIL PROTECTED]
  To: Tomcat User List [EMAIL PROTECTED]
  Sent: Wednesday, December 03, 2003 5:08 PM
  Subject: Global Variables
 
   Is there a way to set global variables in the web.xml which can be read
   by any JSP page?
  
   Cheers,
   -Duncan
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Ben Souther
F.W. Davison  Company, Inc.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Global Variables

2003-12-03 Thread Kannan Sundararajan
in the JSP..

-Original Message-
From: Duncan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 11:50 AM
To: Tomcat Users List
Subject: Re: Global Variables


Thanks for the replies, but what do I define servletContext as?

Many thanks
Duncan

Jardin Xavier wrote:

 use

 context-param
  param-nameparam/param-name
 param-valuevalue/param-value
 /context-param

 in the web.xml

 and String param = servletContext.getInitParameter(param);

 in the JSP.

 - Original Message -
 From: Duncan [EMAIL PROTECTED]
 To: Tomcat User List [EMAIL PROTECTED]
 Sent: Wednesday, December 03, 2003 5:08 PM
 Subject: Global Variables

  Is there a way to set global variables in the web.xml which can be read
  by any JSP page?
 
  Cheers,
  -Duncan
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Global Variables

2003-12-03 Thread Kannan Sundararajan
Sorry, if you are trying to define servletContext , please refer any JSP
book. 

-Original Message-
From: Duncan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 11:50 AM
To: Tomcat Users List
Subject: Re: Global Variables


Thanks for the replies, but what do I define servletContext as?

Many thanks
Duncan

Jardin Xavier wrote:

 use

 context-param
  param-nameparam/param-name
 param-valuevalue/param-value
 /context-param

 in the web.xml

 and String param = servletContext.getInitParameter(param);

 in the JSP.

 - Original Message -
 From: Duncan [EMAIL PROTECTED]
 To: Tomcat User List [EMAIL PROTECTED]
 Sent: Wednesday, December 03, 2003 5:08 PM
 Subject: Global Variables

  Is there a way to set global variables in the web.xml which can be read
  by any JSP page?
 
  Cheers,
  -Duncan
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Global Variables

2003-12-03 Thread Christopher Schultz
Duncan,

and String param = servletContext.getInitParameter(param);

Thanks for the replies, but what do I define servletContext as?
In every JSP, the ServletContext object is implicitly declared with the 
identifier application.

So, you should just be able to do something like this in your JSP:

p
   my_param = %= application.getInitParameter(my_param) %
/p
-chris



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Global Variables

2003-12-03 Thread Ilari Kontinen
 -Original Message-
 From: Duncan [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, December 03, 2003 11:50 AM
 To: Tomcat Users List
 Subject: Re: Global Variables
 
 
 Thanks for the replies, but what do I define servletContext as?
 

An easy way to get the ServletContext from JSP-page is to use the
Servlet-method getServletContext(). So for getting the context
parameter, add the following code-snipped:

% String param = getServletContext().getInitParameter(param); %

And for then on, you can reference it e.g. by:

%= param %

 Many thanks
 Duncan
 
 Jardin Xavier wrote:
 
  use
 
  context-param
   param-nameparam/param-name
  param-valuevalue/param-value
  /context-param
 
  in the web.xml
 
  and String param = servletContext.getInitParameter(param);
 
  in the JSP.
 
  - Original Message -
  From: Duncan [EMAIL PROTECTED]
  To: Tomcat User List [EMAIL PROTECTED]
  Sent: Wednesday, December 03, 2003 5:08 PM
  Subject: Global Variables
 
   Is there a way to set global variables in the web.xml which can be read
   by any JSP page?
  
   Cheers,
   -Duncan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [HOW TO] - GLOBAL VARIABLES - PLEASE HELP

2002-10-18 Thread Mathew Pole
Hi Donie,

The second half of this is you need to know how to access it:

try {
  Context initCtx = new InitialContext();
  String foo = (String)(context.lookup (java:comp/env/foo));
}
catch (NamingException exc) {
  // oops
}

Regards,
   Mathew

--
Mathew Pole 
Web Architect, Gerard Industries
email: [EMAIL PROTECTED] mailto:mathew.pole;clipsal.com.au 
www: http://www.clipsal.com http://www.clipsal.com  
http://www.custompress.com.au http://www.custompress.com.au 
phone: 08 8269 0511 ext 313, fax: 08 8340 1212, mobile: 0403 164 617

 Hi Donie,
 
 You can define a variable in the global web.xml (in conf directory). 
 This variable should be available to all your applications. 
 This should 
 come at the end of the $TOMCAT_HOME/conf/web.xml file.
 
 Though I have not used and tested this (I use for a single 
 application 
 in application specific web.xml) I feel it should work.
 
 env-entry
 descriptionsome description/description
 env-entry-namefoo/env-entry-name
 env-entry-valuebar/env-entry-value
 env-entry-typejava.lang.String/env-entry-type
 /env-entry
 
 Raj

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




[HOW TO] - GLOBAL VARIABLES - PLEASE HELP

2002-10-11 Thread Donie Kelly

Hi all
Sorry for shouting but I've no hair left so it's the only thing I can do :)

Please tell me if it's possible to define a variable in server.xml or
somewhere, which is available to all running webapps.
I've looked in loads of docs and searched the archive but to no avail.

Please please please

Donie




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: [HOW TO] - GLOBAL VARIABLES - PLEASE HELP

2002-10-11 Thread Raj Saini

Hi Donie,

You can define a variable in the global web.xml (in conf directory). 
This variable should be available to all your applications. This should 
come at the end of the $TOMCAT_HOME/conf/web.xml file.

Though I have not used and tested this (I use for a single application 
in application specific web.xml) I feel it should work.

env-entry
descriptionsome description/description
env-entry-namefoo/env-entry-name
env-entry-valuebar/env-entry-value
env-entry-typejava.lang.String/env-entry-type
/env-entry

Raj

Donie Kelly wrote:
 Hi all
 Sorry for shouting but I've no hair left so it's the only thing I can do :)
 
 Please tell me if it's possible to define a variable in server.xml or
 somewhere, which is available to all running webapps.
 I've looked in loads of docs and searched the archive but to no avail.
 
 Please please please
 
 Donie
 
 
 
 
 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]
 



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




global variables from server.xml

2002-10-09 Thread Donie Kelly

Hi all
I want to set a variable in server.xml which can be read by all webapps. How
do I do this?
Donie


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




AW: How to create global variables wich could be accessed by all jsp sites and servlet's?

2001-12-04 Thread Sebastian Hagenbrock

That's it...

Thank you very much.

SH

-Ursprüngliche Nachricht-
Von: Donie Kelly [mailto:[EMAIL PROTECTED]]
Gesendet: Montag, 3. Dezember 2001 16:46
An: 'Tomcat Users List'
Betreff: RE: How to create global variables wich could be accessed by
all jsp sites and servlet's?


Have a look at system.properties
eg:
// Set up new system propeties
sc = getServletContext();
RootPath = sc.getRealPath(/);

propFile = new FileInputStream(RootPath + myapp.properties);

Properties p = new Properties(System.getProperties());
p.load(propFile);
System.setProperties(p);

Run this in some servlet init() method which loads on startup (see
web.xml)

A file like this will then be in your $TOMCAT/webapps/app directory
myapp.properties

# My variable
myvar=myvalue



You can access these variables with

System.getProperty(myvar)

Hope this helps
Donie



--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




How to create global variables wich could be accessed by all jsp sites and servlet's?

2001-12-03 Thread Sebastian Hagenbrock

Hi,

I've found nothing about how to save Variables wich are stored globally in
reference to one context.

Normally I handle the variables in session objects for each user. But I've
some preferences wich should be read only once at the start of the tomcat
server and then always only read by the classes/jsp sites.

I need it, because the initialisation of these variables consumes much time,
and i have running it now for each new created session object. But it is
only needed once at the servers startup.

How to do that?

Thx

SH

PS: Sorry for my bad english.


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: How to create global variables wich could be accessed by all jsp sites and servlet's?

2001-12-03 Thread Ikke List

You may want to use a properties file or much more 'mordern' nowadays,
create  XML file which hold the values.

The Properties class is easier to work with directly I think.

Wouter

-Original Message-
From: Sebastian Hagenbrock [mailto:[EMAIL PROTECTED]]
Sent: Monday, 03 December, 2001 15:36
To: Tomcat Maillist
Subject: How to create global variables wich could be accessed by all
jsp sites and servlet's?


Hi,

I've found nothing about how to save Variables wich are stored globally in
reference to one context.

Normally I handle the variables in session objects for each user. But I've
some preferences wich should be read only once at the start of the tomcat
server and then always only read by the classes/jsp sites.

I need it, because the initialisation of these variables consumes much time,
and i have running it now for each new created session object. But it is
only needed once at the servers startup.

How to do that?

Thx

SH

PS: Sorry for my bad english.


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]





--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: How to create global variables wich could be accessed by all jsp sites and servlet's?

2001-12-03 Thread Donie Kelly

Have a look at system.properties
eg:
// Set up new system propeties
sc = getServletContext();
RootPath = sc.getRealPath(/);

propFile = new FileInputStream(RootPath + myapp.properties);

Properties p = new Properties(System.getProperties());
p.load(propFile);
System.setProperties(p);

Run this in some servlet init() method which loads on startup (see
web.xml)

A file like this will then be in your $TOMCAT/webapps/app directory
myapp.properties

# My variable
myvar=myvalue



You can access these variables with 

System.getProperty(myvar)

Hope this helps
Donie

-Original Message-
From: Sebastian Hagenbrock [mailto:[EMAIL PROTECTED]]
Sent: 03 December 2001 14:36
To: Tomcat Maillist
Subject: How to create global variables wich could be accessed by all
jsp sites and servlet's?


Hi,

I've found nothing about how to save Variables wich are stored globally in
reference to one context.

Normally I handle the variables in session objects for each user. But I've
some preferences wich should be read only once at the start of the tomcat
server and then always only read by the classes/jsp sites.

I need it, because the initialisation of these variables consumes much time,
and i have running it now for each new created session object. But it is
only needed once at the servers startup.

How to do that?

Thx

SH

PS: Sorry for my bad english.


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: How to create global variables wich could be accessed by alljsp sites and servlet's?

2001-12-03 Thread Bo Xu

 -Original Message-
 From: Sebastian Hagenbrock [mailto:[EMAIL PROTECTED]]
 Sent: 03 December 2001 14:36
 To: Tomcat Maillist
 Subject: How to create global variables wich could be accessed by all
 jsp sites and servlet's?

 Hi,

 I've found nothing about how to save Variables wich are stored globally in
 reference to one context.

 Normally I handle the variables in session objects for each user. But I've
 some preferences wich should be read only once at the start of the tomcat
 server and then always only read by the classes/jsp sites.

 I need it, because the initialisation of these variables consumes much
time,
 and i have running it now for each new created session object. But it is
 only needed once at the servers startup.

 How to do that?

 Thx

 SH
[...]


there are already other ways in other repling-emails, the following is my
suggestions:

if you want to make your Variables visible inside-context,  I think you also
can
save them with:
 - javax.servlet.ServletContext.getAttribute/setAttribute
 - use a class which wrap your variables as a data container,
   and put this class together with your Servlet class.

if you want to make your Variables visible cross-context,  I think you also
can
save them with:
 - use a class which wrap your variables as a data container,
   and put this class in JAKARTA_HOME/common/classes or
  JAKARTA_HOME/shared/classes(JAKARTA_HOME/classes)


Bo
Dec.03, 2001



--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]