This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes using getInitParameter in a simle java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "using getInitParameter in a simle java class" Watch "using getInitParameter in a simle java class" New topic

using getInitParameter in a simle java class

nitish dhar

Joined: Aug 19, 2007
Posts: 11
please tell me how to use
in a simple java class ,i mean which does not extend a servlet

i tried it by implementing the ServletContext interface and then used the

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

If the class runs in a servlet container, it should have access to the container (typically through the servlet, but there are other ways) in order to access the ServletContext and then the initial parameters.

If you're not running in a container, why would you need the initial parameter.
Soniya Ahuja
Ranch Hand

Joined: Jul 20, 2008
Posts: 83
Could you specify why you need initialization parameters? If you just need to pass some values, there are other ways. Initialization parameters, as the name suggests are for values that are needed typically during Context initialization or a servlet (config) initialization.

Please specify your purpose of using the params so that we can suggest a workaround

SCJP 1.5 | SCWCD 5 | SCJP 6.0
[url][/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
I agree. Here's the link:
subject: using getInitParameter in a simle java class
It's not a secret anymore!