• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ConstantsUtil class

 
prasad naga
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
can any body explain me about ConstantsUtil class and why do we initialize it in init() of servlet.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never heard of it
Where did you see it ? In a book ?
 
prasad naga
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic