You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Duncan <ds...@deckertelecom.net> on 2003/12/03 17:08:29 UTC

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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Global Variables

Posted by Ben Souther <bs...@fwdco.com>.
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-name>Welcome to Tomcat</display-name>
  <description>
     Welcome to Tomcat
  </description>


<context-param>
 <param-name>param</param-name>
    <param-value>value</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-name>param</param-name>
> >     <param-value>value</param-value>
> > </context-param>
> >
> > in the web.xml
> >
> > and String param = servletContext.getInitParameter("param");
> >
> > in the JSP.
> >
> > ----- Original Message -----
> > From: "Duncan" <ds...@deckertelecom.net>
> > To: "Tomcat User List" <to...@jakarta.apache.org>
> > 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: 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

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



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


Re: Global Variables

Posted by Christopher Schultz <ch...@comcast.net>.
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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Global Variables

Posted by Duncan <ds...@deckertelecom.net>.
Thanks for the replies, but what do I define servletContext as?

Many thanks
Duncan

Jardin Xavier wrote:

> use
>
> <context-param>
>  <param-name>param</param-name>
>     <param-value>value</param-value>
> </context-param>
>
> in the web.xml
>
> and String param = servletContext.getInitParameter("param");
>
> in the JSP.
>
> ----- Original Message -----
> From: "Duncan" <ds...@deckertelecom.net>
> To: "Tomcat User List" <to...@jakarta.apache.org>
> 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: 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


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


Re: Global Variables

Posted by Jardin Xavier <xj...@sofice.fr>.
use

<context-param>
 <param-name>param</param-name>
    <param-value>value</param-value>
</context-param>

in the web.xml

and String param = servletContext.getInitParameter("param");

in the JSP.


----- Original Message ----- 
From: "Duncan" <ds...@deckertelecom.net>
To: "Tomcat User List" <to...@jakarta.apache.org>
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: 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