Ok, heres the idea. In a JSP page, could I instantiate a bean (application
scope) that is threaded and start it running? To my knowledge there is
nothing in the spec stopping it. Basically, my plan is this:
When a certain jsp page is accessed, it instantiates an application scope
bean, based roughly on something like this:
(please ignore any mistypes)
public class ServerBean extends Thread
{
public ServerBean()
{
super();
start();
}
public void run()
{
ServerSocket listener = new ServerSocket(8080);
Socket newConnection = listener.accept();
// Do something here
newConnection.close();
listener.close();
}
}
Also included on the jsp page would be an applet that connects to the
server and sends and recieves some data.
I could just do this by setting off a new process on the server, but I
don't have the access for that. I am just web-development. This seems
perfect for say a chatroom. The entry page instantiates the ServerBean, or
not if it already exists, then sends an applet for chatting.
Another thought, if I had the bean as page/request scope, would the bean
still be valid after the page/request had ended? I assume that the JSP
engine would wait for the thread to die, and wouldn't explicitly kill off
all threads. What about session scope? Is there a way of finding out if the
session had died, so the thread could die as well?
Any help greatly appreciated.
Dave
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html