One standard way is to create your own request handler objects and put them
in a hash table with the request name/type as the key.  Or, put the objects
in
an array sorted by the request name/type and do a binary search to find the
right one.

-----Original Message-----
From: t t [mailto:[EMAIL PROTECTED]]
Sent: Saturday, July 14, 2001 6:26 AM
To: [EMAIL PROTECTED]
Subject: Servlet Design Question-Want to get rid of massive if/else
block


Hi Folks

I have just started writting Servlets and want advice
on how to write a handler for all incoming requests.
At the moment I have all requests going to the same
servlet.  This servlet grabs a hidden variable which
says which page the client is requesting, ie

requestPage=mainMenu

the servlet then looks at this variable in a big
if/else block and determines what the user wants to do
and then calls the appropriate handler for this
request.  This looks messy to me and I want to know
how other people tackle the problem.  Can someone
please give me some insight into other ways of
writting this main handler.




Cheers

Tony


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to