aspose file tools*
The moose likes Servlets and the fly likes can we assign a servletconfig object to global variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "can we assign a servletconfig object to global variable" Watch "can we assign a servletconfig object to global variable" New topic
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: 61437
    
  67

Not something I would advise.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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: 61437
    
  67

An instance variable of what? How would that be thread-safe?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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: 61437
    
  67

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: 8919

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".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can we assign a servletconfig object to global variable