You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Ilkka Heinonen <il...@vtt.fi> on 2004/12/09 10:40:50 UTC
How to add variables into WEB-INF/web.xml or META-INF/*.* ?
Hello everyone.
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).
Some examples that I need to make parametric:
- JDBC/ODBC name
- Official Project name
- Project description
- Project logo location
Do you have the way how to make this true?
How u can use variable values in java code?
Thanks in advance
.
-Ilkka Heinonen-
Re: How to add variables into WEB-INF/web.xml or META-INF/*.* ?
Posted by Ben Souther <bs...@fwdco.com>.
One more thing...
This question belongs in the Tomcat User's List.
The dev list is for people who are building Tomcat.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
Re: How to add variables into WEB-INF/web.xml or META-INF/*.* ?
Posted by Ben Souther <bs...@fwdco.com>.
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