| Author |
can we assign a servletconfig object to global variable
|
srinivas yakala
Greenhorn
Joined: Dec 09, 2005
Posts: 12
|
|
hi, can we assign a servletconfig object to global variable . ie in init() we are not specified the argument and is there any way to invoke the servlet config object to assign in global. means, init(){ } in parameters we are not specified the servletconfig. thanks in advance regards srinivas.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
|
Not something I would advise.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Originally posted by Bear Bibeault: Not something I would advise.
I dont see any problem if ServletConfig is assigned to an instance variable. Could I know the reason ?
|
Groovy
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
|
Sounds useless to me. I would ask, why on the earth you want to do that??
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
|
An instance variable of what? How would that be thread-safe?
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Originally posted by Bear Bibeault: An instance variable of what? How would that be thread-safe?
An instance variable of ServletConfig in a servlet. ServletConfig has only get methods so thread safe is not any issue.  [ February 06, 2006: Message edited by: Pradip Bhat ]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
What would be the point? The servlet config is readily available in a servlet. The OP is talking about a general global variable, probably to try and avois passing context objects to other classes.
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Originally posted by Bear Bibeault: What would be the point? The servlet config is readily available in a servlet. The OP is talking about a general global variable, probably to try and avois passing context objects to other classes.
I agree the servletconfig config object is readily available and only advantage of storing in an instance variable is to save typing few more key strokes. I thought the OP was talking about instance variable so I asked the question. If he/she meant something else you are right. It wont be thread safe. Thanks Bear for clarification.
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
Originally posted by Bear Bibeault: What would be the point? The servlet config is readily available in a servlet.
Cause of this very point, I said, "It sounds useless to me".
|
 |
 |
|
|
subject: can we assign a servletconfig object to global variable
|
|
|