tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Souther <bsout...@fwdco.com>
Subject Re: How to add variables into WEB-INF/web.xml or META-INF/*.* ?
Date Thu, 09 Dec 2004 11:20:32 GMT
I should want to add variables like ODBC name into
> %Tomcat-webapps%/WEB_INF/web.xml. How can you do it? How do you use it in
> java code (jsp, servlet, basic class).

You will want to read up on context initialization parameters and
servlet initialization parameters.

For a context init param (application wide) you would enter
something like this in your web.xml file:

  <context-param>
    <param-name>
      welcome-message
    </param-name>
    <param-value>
      The value of this message is stored in a context init param
    </param-value>
  </context-param>
                                                                                         
        
Then to retrieve the parameter from a servlet:
getServletContext().getInitParameter("welcome-message"));

or from a JSP:
<%=application.getInitParameter("welcome-message")%>


If you're interested, there is an example app you can download at:
http://simple.souther.us

look for Simple Context Init Params






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


Mime
View raw message