Results 1 to 4 of 4
  1. #1
    urbanleg is offline Member
    Join Date
    Jul 2011
    Posts
    25
    Rep Power
    0

    Default 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?

  2. #2
    urbanleg is offline Member
    Join Date
    Jul 2011
    Posts
    25
    Rep Power
    0

    Default 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?)..

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default 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?

  4. #4
    urbanleg is offline Member
    Join Date
    Jul 2011
    Posts
    25
    Rep Power
    0

    Default Re: JSP with server persistant world question

    update: the thread is running !

    and for the other problem. i managed to find another solution:

    DWR (AJAX)

    thanks!

Similar Threads

  1. Newbie question about basic code - "Hello World"
    By Kimomaru in forum New To Java
    Replies: 3
    Last Post: 10-13-2011, 06:56 PM
  2. A question on JDBC&SQL Server
    By an24 in forum JDBC
    Replies: 5
    Last Post: 01-18-2010, 11:23 AM
  3. Server and db Question
    By SamuelM in forum Forum Lobby
    Replies: 2
    Last Post: 12-30-2009, 06:58 PM
  4. Multi Client/Server Chat Question
    By Kodak07 in forum Networking
    Replies: 3
    Last Post: 03-29-2009, 10:50 PM
  5. server question
    By Peter in forum New To Java
    Replies: 1
    Last Post: 07-09-2007, 01:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •