----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
--- Fernando Salazar <[EMAIL PROTECTED]>
wrote:
> >My main question is whether there is a built-in way
> of protecting
> >oneself from a user who refreshes his browser many
> many times?
Nope.
But while this may cause your web process gang to
consume more memory and steal more processing time
from more normal requests, it should NOT cause your
servlet to get "confused".
Try writing some code in the servlet's main() method
to throughly test all the interior methods of the
servlet. If you are seeing something strange and are
still stumped, use a debugger and step though it line
by line. eg: JBuilder's debugger can step through even
complex multi-threaded code while keeping you from
getting confused as to what thread you're in. This is
how I do basic unit testing for all my code written in
Java: it's a good practise to get into. If you follow
my advice, you will find that code you deliver can be
as near as 100% bug-free as a human can ever do:
remember, if it isn't tested, it isn't done and for
every line of code you write, you may write a line of
code to test it.
Secondly, even if you plan to use green threads in
production, use native threads in development anyway.
Green threads can sometimes hide thread-saftey issues
that becoming glaring when using native threads. Note
that native threads will often appear slower than
green threads unless you are using a threadpool.
Third, mySQL: I remember now mySQL doesn't support
transactions. I believe you still need to committ
after each transaction, but I would look it up or
defer to others that have used jdbc with things like
Oracle and mySQL both. I have experience with only
Oracle and Sybase, and these definitely will run out
of cursors if you don't commit your reads.
Finally, I can't think of a reason why you should need
to synchronize any servlet unless you are accessing
resources that are inter-servlet accessable.
Synchronization is bad: executing sync'd code can be
as slow as 10 times slower than code written to
support inter-woven threads of execution because the
VM must expend resources obtaining a monitor-lock on
the object, which is expensive.
=====
# Nick Bauman
# Technical Programmer
# http://webhelp.com
# real people, real answers, real time
__________________________________________________
Do You Yahoo!?
Thousands of Stores. Millions of Products. All in one place.
Yahoo! Shopping: http://shopping.yahoo.com
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]