This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 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: 39578
    
  27
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 - updated with new look and Ping home screen widget
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
can non-static inner class access any member
Doubt about diagram class (realization)
Doubt about diagram class
WA #1.....word association
andrew has wii