Results 1 to 4 of 4
- 12-14-2011, 09:27 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 25
- Rep Power
- 0
JSP with server persistant world question
Hi,
my goal is to take an application i already built in standard java 1 year ago..
this application simulates a persistent world (animals , resources, prey, predators etc...)
I would like to create a web application for people to connect into my website and get a visual information about that world that runs on my web server persistently...
They will be able to interact and stuff...
i started to work with jsp in order to create the dynamic pages for each user request (every user that connects should get different info\webpage since the world is changing constantly)
how do i run the world application in conjecture to my jsp server?
ive tried to put the following code in the beginning of my jsp file:
<code>
<%
if (firstTime) {
Thread worldThread = new Thread(new worldEngine());
worldThread.start();
firstTime=false;
}
%>
</code>
the idea here : the first user will create an instant of the new world and it will start to run...
for the next users it should be already running... and hopefully i will be able to use it in my jsp...
THE PROBLEM IS: after the first user joins, my server wont handle any other requests...
(it appears that the server waits for the thread to stop)
help?
- 12-14-2011, 10:04 PM #2
Member
- Join Date
- Jul 2011
- Posts
- 25
- Rep Power
- 0
Re: JSP with server persistant world question
maybe ill say it in other words:
I have created a standard java application that runs infinitely. (and do some logic)
I would like to setup a web-server that for each user request - will dynamically create a webpage (VIA JSP) that defines the application state in that specific time.
My question is:
where do i run\start the application ? i mean, it supposed to run indefinitely on the background.
i thought maybe make this app as a thread, and when the first user make a HTTP request , a jsp code makes a new thread and start it..
problem is: when i do that the web-server not responding to new requests. (i guess it waits for the thread to stop?)..
- 12-15-2011, 09:27 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: JSP with server persistant world question
Firing off a thread should not cause the server to lock up.
It is, after all, done all the time on web servers.
What server are you on?
- 12-15-2011, 04:44 PM #4
Member
- Join Date
- Jul 2011
- Posts
- 25
- Rep Power
- 0
Similar Threads
-
Newbie question about basic code - "Hello World"
By Kimomaru in forum New To JavaReplies: 3Last Post: 10-13-2011, 06:56 PM -
A question on JDBC&SQL Server
By an24 in forum JDBCReplies: 5Last Post: 01-18-2010, 11:23 AM -
Server and db Question
By SamuelM in forum Forum LobbyReplies: 2Last Post: 12-30-2009, 06:58 PM -
Multi Client/Server Chat Question
By Kodak07 in forum NetworkingReplies: 3Last Post: 03-29-2009, 10:50 PM -
server question
By Peter in forum New To JavaReplies: 1Last Post: 07-09-2007, 01:39 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks