tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Brogden <>
Subject Re: Running a thread from a JSP
Date Tue, 26 Dec 2000 19:53:43 GMT

"David M. Holmes" wrote:
> We have a custom tag that is in every JSP that creates a socket connection to a target
server and
> POSTs some data do a page on the target server that writes the data to a database. The
issue we
> are having is that we don't want to delay the user's response by doing the socket connection
> synchronously. If we do the socket connection asynchronously we risk having the data
not being
> sent when the server is under stress. I have not verified that this is occuring with
the custom
> tag yet, but we are seeing it happen using ASP with an HTTP component. I am pretty sure
that the
> same condition will occurr. So I would like for the JSP to start a thread to do the socket
> connection, run in the background, and return the response immediately so there is no
delay to the
> user. I am thinking that when the response finishes the thread that it started will also
die. Is
> that correct?

That should work just fine - I have done something very 
similar to send email. You might want to provide for logging
the data to a file if the socket connection fails.
When the job is done, the Thread falls out of the run
method and dies - all very neat.

Java Cert mock exams
Author of Java Developer's Guide to Servlets and JSP 
ISBN 0-7821-2809-2

View raw message