Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

processing request using if-then-else

843841Feb 16 2005 — edited Feb 16 2005
The code in my servlet method which processes the request contains a long if else statement and I'm not sure if this may be an indication that I've not written the method well. The method process request, called from doGet and doPost asks about the presence of various parameters in order to determine what code should execute. So it looks like this...
        if the paramater "foo" is defined
                then do this
        else if parameter "bar" is defined
                then do that
        else if the request URI contains the following string "foobar"
                then do something else
        ...... so on.....
        end if
And this looks wrong to me from the standpoint of object oriented development. But maybe it's fine considering this is a servlet and maybe this sort of thing is supposed to take place. Is this sort of code inevitable in a servlet or avoidable in general in OOP...

I appreciate and welcome any feedback.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 16 2005
Added on Feb 16 2005
5 comments
249 views