Milt Epstein wrote:

> On Thu, 16 Sep 1999, Steven J. Owens wrote:
>
> [ ... ]
> >      Frankly, I override the service() method.  Various people have
> > said "this is bad" but I've never actually heard a coherent, cogent
> > explanation of why it's bad.  99% of the time you don't really care
> > whether they use GET or POST.  The main reason not to use GET is for
> [ ... ]
>
> Or perhaps you just didn't appreciate those explanations.  What the
> default service() does is very nice, farming requests out to
> appropriate doXXX() methods.  So when you want to do different things
> with GET and POST (or whatever) HTTP methods, it's very nice.  And
> still it's very easy to handle the case when they do the same thing.
>
> Perhaps you've only worked with servlets that do the same thing with
> GET and POST.  But that doesn't mean that 99% of applications work
> that way.  And if you ever have to change, it'll be a lot easier if
> you had just left service() alone in the first place.
>
> In addition, not having heard a compelling argument for not overriding
> service() is *not* a compelling argument *for* overriding service().
>
> Milt Epstein

While agreeing with Milt's reasoning, I would point out at least one
significant feature that you give up when you override the service() method --
conditional GET support.  This allows your servlet (if it appropriately
implements the getLastModified() method and does *not* override the standard
service() method) to send back a NOT_MODIFIED response to the client, and thus
avoid having to download a page that has not changed since the last time it
was requested.

This is probably not noticeable if you are talking to a web server on your own
machine, or even on a local area network.  But if you're sending large pages
(or dynamically generated images, or anything else you can create with a
servlet) that do not change often, to a user at the other end of the country,
who is connected to the Internet via a slow modem ... the effective response
time of your application suddenly looks a lot better.  Overriding the
service() method means you will have to support this for yourself if you want
it.

Craig McClanahan

___________________________________________________________________________
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