Remember that the init parameters are available to your servlet/jsp when those servlet/jsp's are being initialized...i.e. when their init() methods runs. On the other hand your attributes are available only when the service method runs. So if you want any information along with your servlet initialization, then initParameters to the rescue...Hope you understood...
ServletContext's getInitParameter is just here for convenience. It simply calls ServletConfig's. Attributes is a different story. You set attributes in the context, so it should not be in ServletConfig. Init parameters are set in web.xml, so they can be considered both as being part of the config and the context. (that's how I see it )
Because they return different init parameters. The context configuration (of which there is a single one for a web app) is not the same thing as the servlet configuration (of which there is one for each servlet).
Cant we get it using getAttribute methods in both?
Init parameters are not attributes, and thus can't be accessed via getAttribute. [ June 25, 2007: Message edited by: Ulf Dittmer ]
Ping & DNS - updated with new look and Ping home screen widget
Joined: Oct 21, 2005
ok..so cant I use getattribute in the init method???
Joined: Mar 22, 2005
Posted by Renu Radhika so cant I use getattribute in the init method?