Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Init parameters in Servlet and ServletContext

796254Jan 15 2004 — edited Jan 15 2004
Init parameters for a servlet are specified in web.xml, using the <init-param> child of the <servlet> tag.

These can be accessed using the javax.servlet.GenericServlet.getInitParameter(). So far, so good.

There's also a getInitParameter() method in the javax.servlet.ServletContext class. I thought it, too, gave access to the <init-param> values.

But in my application, ServletContext doesn't provide access to the init param names. My servlet does call
"super.init(config);" in the first line of its init() method. I've been able to make them available outside the init method by adding them to the servlet config as attributes, but I'd like to understand what's happening.

It appears that the init params of the servlet and its context are different. Can someone clear up this
misunderstanding for me? Thanks - MOD
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 12 2004
Added on Jan 15 2004
7 comments
596 views