This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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...
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
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 ]