Kito Mann ([EMAIL PROTECTED]) writes:

> I took a look at the previous thread, and I'm still not
> convinced. If you know you want your servlet to respond only to GET
> and POST methods, what's the problem with calling doGet and doPost
> yourself, preceeded by custom error checking?

     Turn it around?  Why bother?  True, it's a bit unaesthetic to
have to have doGet() forward to doPost(), but a lot less unaesthetic
than mucking up with service() and all the other do...() methods.
And putting it in service() doesn't buy you anything.

      This whole thing is a mountain out of a molehill; it's not that
there are dire problems with putting it in service(), simply that
there're no good reasons to do so, and some mild reasons for not doing
so.

> It's true it'd be somewhat annoying to add an extra line or two in
> order to add additional methods, but how often does this happen?

     An extra line or so?  You'd have to add code to check for other
request types, then add switch code or if/else to have different code
to respond to each request type, and along about now you've either got
a monster method, or you're starting to think about separating out the
body of each case into its own method and just having service() be the
switchboard, and now we're back to square one.

     Either that or you check for the request types you do want (GET
or POST) and then do somethinkg funky like call super() to handle the
other requests, which starts to get awkward and ugly.  Why not just
pass it down to doPost or doGet?

> I guess the real quesiton is how much code is normaly in the
> service() method other than dispatching code... If there is often a
> lot of stuff in there, then I can see how it'd be a problem (I admit
> I haven't looked at the source for that method)...
>
> I personally think you should use doGet() and doPost() to handle
> those specific requests, but if any code is common to all requests,
> service() seems like a good place to put it... (of course, you could
> have a method, "preProcess()" which all of your handlers call, but
> that's another issue <grin>...).

     Hm, that's a bit subtler of an issue; I guess in theory if some
code needs to be invoked for all requests, regardless of type, putting
it in service() does make some sense.

Steven J. Owens
[EMAIL PROTECTED]
[EMAIL PROTECTED]

___________________________________________________________________________
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