On Tue, 24 Aug 1999, Sam Rose wrote:

> Hello,
>
> I was just wondering, which is better to use.
> I am posting and retrieving data to and from a database.
>
> Should I use doGet() or doPost()?
>
> Or do I do what I have been doing and do this?
>
> public synchronized void doanything (HttpServletRequest req,
> HttpServletResponse res) throws ServletException, IOException {
> }
>
> public synchronized void doGet (HttpServletRequest req, HttpServletResponse
> res) throws ServletException, IOException {
>       doanything(req, res);}
>
>  public synchronized void doPost (HttpServletRequest req,
> HttpServletResponse res) throws ServletException, IOException {
>      doanything(req, res);}

If you're suggesting this as an alternative to putting all the code in
one of doGet()/doPost() and having the other one call it, I don't
really see much difference.  Either seems reasonable for the situation
where you want the same behavior with GET or POST.

However, those synchronized's scare me.  I gather you're putting them
in to make things thread-safe, but synchronizing the entire
doGet()/doPost() method seems a shotgun approach when more precision
shooting would serve better.  I think it would be better to analyze
your code more closely, and isolate the synchronized's to as small a
block (or blocks) as possible.

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

Reply via email to