title: Architecture of Website based on java
body: <p>I've just started programming with Java, so might appear as silly question, but I was not able to find simple answer on the internet. This is "big" question which I have to answer before getting too deep into development, so you can help me to save a lot of time on trying different approaches.</p>
  
  <p>I am currently creating a website using Java. Important feature of this website would be realized through separate Java thread (like daemon) which must be run in background for as long as the user is on the website. At the sametime, website applets must have means of communication with this thread.</p>
  
  <p>I see three potential solutions to this:</p>
  
  <ol>
  <li><p>Create traditional multipage website with stand-alone java applets in each separate page. I am not sure if it is possible, the following questions arise:</p>
  
  <ul>
  <li>is it possible for java thread created by java applet to continue execution after user navigated to another webpage (on the same website)? I assume that yes.</li>
  <li>is it possible for newly launched java applet to communicate with java thread already running in background? (I've seen part of documentation covering communication between java applets through JavaScript, not sure that this can be used in my case. Any other options?)</li>
  </ul></li>
  <li><p>Create single-page website, with one single java applet, responsible for all navigation and rendering all pages. This solves the problem with background daemon, which becomes easy to implement and communicate with, as part of single applet, but raises one more questions:</p>
  
  <ul>
  <li>I know that applet can modify current webpage. Is it feasible to use this feature to simulate navigation between different pages?</li>
  </ul></li>
  <li><p>Create Java Webstart application, basically by taking the single java applet from p.2 and converting it into stand alone application.</p></li>
  </ol>
  
  <p>I want the whole thing to have a look and feel of website, so I would prefer option 3 over option 2 and option 1 over option 2.</p>
  
  <p>Thank you for any thoughts you share.</p>
  
  <p>UPDATE:
  Does anybody know answers specifically to the two questions under p1? If it is possible to work with java threads the way described?</p>
  
  <p>Now I would most probably opt for making a Java Webstart Application. This should be the least painful way.</p>
  
  <p>UPDATE 2:
  I finally decided to work on single java applet, which can be easily converted to JWS application if needed. Nature of my project is that I need to make impression of working with website, that's why I am putting additional efforts to make it appear as a website. For knowledgeable people it will be obvious, that it is more like a local application.
  Solution I chose has following benefits in my situation:
  - easily convertable from JWS application to Java applet and back.
  - no problems with running background thread and communicating with it.
  - more reliable security (meaning that I don't need to use any mechanisms to pass over session ids from one applet to the other)</p>
  
  <p>Contras:
  - if size gets large, start up will be slow - I hope to avoid this.
  - Security issues - I tried signing the applet and it helped a lot.
  - Work of navigation buttons in browser (back and forth) - I hope to be able to replicated it in applet. Think applet should be able to catch this event.</p>