On Fri, 17 Dec 1999, Kito Mann wrote: > Ron, > > Like everything else, I don't think there's a simple > answer. Generally, I stick to the main point of a GET request > (querying info) and a POST request (posting data). I generally use > service() for any processing which is used by all types of > requests. So my code typically has general code (such as user > checking) in the service method, and then calls doGet() or doPost() > to handle the request. But, if your servlet responds the same for > GET and POST requests, there's really no reason to use the > individual handlers. I disagree, I think there is a simple answer :-). And that answer is: Don't override the default service() (and lose all the functionality it contains) unless you have a very good reason for doing so (and "GET and POST behave the same in my servlet" is *not* a good reason). This has been discussed before on the list, and some of the key points have been mentioned here again as well, and this is the conclusion I have come to. Really, how difficult is it to have doGet() call doPost() (or vice-versa) to get them to do the same thing. The extra work compared to just overriding service() is minimal. And it makes it less intuitive and conventional. And if things ever change where you want to have doGet() and doPost() behave differently, and/or you want to use some of the default service() functionality, you've increased the work you need to do (not greatly, of course). Isn't writing for maintainability one of the key issues in software design? > [EMAIL PROTECTED] > Friday December 17, 1999 02:11 AM > > Please respond to [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > cc: (bcc: Kito Mann/PSG/Prudential) > Subject: Re: [design] set of servlets that require login > > > i don't even overload doPost() and doGet() anymore in my servlets - i go > straight to service(). is that bad if i don't treat posting vs. getting > differently? i can't imagine why, but in case anyone has a good reason not > to do it that way i'd be happy to hear it. > ...............ron. > -----Original Message----- > From: Danny Rubis <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] <[EMAIL PROTECTED]> > Date: Thursday, December 16, 1999 3:13 PM > Subject: Re: [design] set of servlets that require login > > > >Hey! > > > >I must say that I am very interested in your LoginServlet design. > > > >You say >>>>>>> > >I'm turning all requests into POSTs, but that's kind of > >"rude", as some sub-class servlets may behave differently in the case of > >POST than GET. (I can't think of a reason why; generally, I either > >implement only POST b/c the servlet's action is not idempotent, or I > >implement doGet and then make doPost simply call doGet. But LoginServlet > >will be sub-classed by other developers, and I can't constrain them this > way.) > >>>>>>>> > > > >I am one that has implemented POST and GET differently in some cases. I > >would hate to give this up. [ ... ] Milt Epstein Research Programmer Software/Systems Development Group Computing and Communications Services Office (CCSO) University of Illinois at Urbana-Champaign (UIUC) [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
