• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we assign a servletconfig object to global variable

 
srinivas yakala
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not something I would advise.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds useless to me. I would ask, why on the earth you want to do that??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An instance variable of what? How would that be thread-safe?
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic