aspose file tools*
The moose likes Servlets and the fly likes ServletContext InitParameter Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContext InitParameter Problem " Watch "ServletContext InitParameter Problem " New topic
Author

ServletContext InitParameter Problem

Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Hello All,
Can you tell me what is the use of context.getInitParameter() or context.getInitParameterNames() . where we should define init parameters for Context. (Referring to text in bold context is of type ServletContext.)
What is the difference between context.getAttribute() or context.getAttributeNames() & getInitparameter() & getInitParameterNames()?
when i am using the following code on Tomcat 5.0 it shows the outputas given below:






//====================================================================
OUTPUT in web browser
//====================================================================
Printing context-param elements from web.xml...

DB_Driver : sun.jdbc.odbc.JdbcOdbcDriver
DB_UserName : scott
DB_URL : jdbc dbc:MyDataSource
DB_Password : tiger
Printing after manipulating the Context Prameters...

Company Name : SEED INFOTECH PVT. LTD. PUNE
Login Name : Seed
Password : null
//=========================================================================

It is not showing me any initparameter in the output can you help me to understand hoe init parametres can be specified & what would be its use?



Thanx in Advance
Shrinivas Mujumdar

[Code tags fixed]
[ August 27, 2005: Message edited by: David O'Meara ]
te zhang
Greenhorn

Joined: Aug 25, 2005
Posts: 6
if you want to get the InitParameter
since the initparameters are configued in the configuration file.
the web.xml, so the config object must be getten.
javax.servlet.ServletConfig
using the above class generate the config object ,you can
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

All the answers to your questions can be found in the API:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html

If you would like an example app that uses context init params I have one on
http://simple.souther.us.
There is also one for servlet init-params.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ServletContext InitParameter Problem