This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes ConstantsUtil class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ConstantsUtil class" Watch "ConstantsUtil class" New topic
Author

ConstantsUtil class

prasad naga
Greenhorn

Joined: Jan 05, 2006
Posts: 10
Hi
can any body explain me about ConstantsUtil class and why do we initialize it in init() of servlet.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41127
    
  45
Welcome to JavaRanch.

Is this the class you're talking about? It's the only class of that name Google knows about. I think that would more properly be a question to whoever wrote the code you're looking at, as it's not a commonly used class.


Ping & DNS - my free Android networking tools app
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Never heard of it
Where did you see it ? In a book ?


[My Blog]
All roads lead to JavaRanch
prasad naga
Greenhorn

Joined: Jan 05, 2006
Posts: 10
no i haven't viewed in any book, i just saw in my project which consists of
ConstantsUtil class that imports java.lang.reflect.Field and declares a constants like SERVLET_SUFFIX,SERVLET_METHOD,ACTION,ITEM,etc..
Here the ACTION AND ITEM were the variables that are to be declared.(i.e which were avilable in the jsp) and apart from this which consists of a method that returns Hashmap.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by prasad naga:
no i haven't viewed in any book, i just saw in my project which consists of
ConstantsUtil class that imports java.lang.reflect.Field and declares a constants like SERVLET_SUFFIX,SERVLET_METHOD,ACTION,ITEM,etc..
Here the ACTION AND ITEM were the variables that are to be declared.(i.e which were avilable in the jsp) and apart from this which consists of a method that returns Hashmap.


Sounds like implementing Command Pattern using HashMap.
Where is the problem?
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by prasad naga:
can any body explain me about ConstantsUtil class and why do we initialize it in init() of servlet.


You people are initializing that in your init() because your servlet is most probably working as a FrontController. The servlet need to check the command/action (Key in a HashMap object) to get the corresponding handler object in order to fulfill the request. So, the HashMap must be initialized before start serving the requests.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ConstantsUtil class
 
Similar Threads
Doubt about diagram class (realization)
WA #1.....word association
can non-static inner class access any member
andrew has wii
Doubt about diagram class