Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes getInitParameter() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getInitParameter()" Watch "getInitParameter()" New topic
Author

getInitParameter()

Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
Hi, I have a question about the method getInitParameter(String parameterName). When we invoke this method, do we call it as ServletConfig.getInitParameter() or just getInitParameter()?
I have seen some example use one and some the other.
Thanks.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
The method getInitParameter( String name ) is an instance method of ServletConfig. You can get the ServletConfig object for a servlet when it is passed to init or your can get it anywhere in the servlet class by:
getServletConfig()
Important: if getServletConfig() returns null, you probably forgot to have your init method call super.init
public void init(ServletConfig conf ){
super.init( conf );
.....
}
Bill

------------------
author of:
Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getInitParameter()
 
Similar Threads
Get parameter from web.xml file
How do you set a servlet context attribute?
init param doubt
Doubt in getInitParameter( String name )
getServletConfig() and getServletContext()