Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ServletContext InitParameter Problem

 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic