This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "using getInitParameter in a simle java class" Watch "using getInitParameter in a simle java class" New topic
Author

using getInitParameter in a simle java class

nitish dhar
Greenhorn

Joined: Aug 19, 2007
Posts: 11
please tell me how to use
getInitParameter
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
Rancher

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]http://a2zjava.webs.com[/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
http://soniyaahuja.webs.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: using getInitParameter in a simle java class
 
Similar Threads
Servlet's "configuration" parameters
Doubt in getInitParameter( String name )
accessing initialization parameters
Question about when to import or not
ServletContextListener not working