----------------------------------------------------------------
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
> Assuming your servlet is thread-safe and all, the quick way is to
> synchronize on the client session object. That way, multiple threads
> cannot be handling requests from the same client simultaneously, but
> they can handle requests from different clients simultaneously.
I think the best thing is to check the time in the session object and
immediately reply with a brief -- "please be patient" message, if the
user over does it.
But, is there no built-in protection against this kind of assault?
> Example:
>
> void doPost(...)
> {
> HttpSession session = req.getSession( true );
> synchronize(session)
> {
> // handle the request
> // any other thread that tries to synch on the
> // same instance of session will block
> }
> }
>
Synchronizing on the session object is certainly a smart idea
> I don't think this will make for great performance, though. Let's
> say your fast-refreshing user spins up 3 threads waiting on their
> requests ... those are threads unavailable to service other clients.
> Long term, you might want to think about something like caching the
> output from your DB in the session object, and when a request comes in
> and you have data in the cache, just send the cached data and don't
> hit the database. Of course, you need a timeout for refreshing the
> cache, so on and so forth.
>
> - Fernando
Gracias para tus sugerencias.
Saludos,
Hasan
Hasan
~~~~~ HASAN BRAMWELL
Address: Casilla 17-17-1004, Quito, Ecuador Tel : (593) (2) 372-748
Internet: [EMAIL PROTECTED] or : (593) (9) 722-221
--
--------------------------------------------------------------
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]