This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Servlets and the fly likes Difference between attributes and parameters. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference between attributes and parameters." Watch "Difference between attributes and parameters." New topic

Difference between attributes and parameters.

Rachit Kumar Saxena
Ranch Hand

Joined: Dec 24, 2011
Posts: 50
While theres a getInitParameter method,theres no setInitParameter method in ServletContext CLASS.But you can also set and get an attribute.Why?What is the difference between parameters and attributes?
Ashish Hiriadka

Joined: Feb 27, 2011
Posts: 5
ServletContext Init parameter are for passing any values which doesn't change very often. So there is no setInitParameter() method in servlet context.
Rachit Kumar Saxena
Ranch Hand

Joined: Dec 24, 2011
Posts: 50
Thanks for the reply!!! But I would like to know IF setInitParameter had been used,it would have given the user the option of changing init parameters in java apart from the xml file.Your views?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63227

Speculation is useless -- init parameters are intended to apply constant values for the servlet instance.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pawan Singh

Joined: Jun 05, 2012
Posts: 9
init parameters are loaded along with servlet, that is at it's one time instanciation time, while attribute are the object which are passed , set, and get at run time when we need them......
I agree. Here's the link:
subject: Difference between attributes and parameters.
It's not a secret anymore!