• Post Reply Bookmark Topic Watch Topic
  • New Topic

novice Query about Applications

 
Tom Hill
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya - I'm just wondering how you about this:

I have an application that takes ages to run.
I want a user to be able to go to website and start the application running.
Once its running I want to be able to view the state of various objects that I could reference.
I'm thinking the easiest way would be to have the server store the references to the objects, pass the objects to the application and call them when necessary.
I dont want the user to have to keep their browser open while processing - Id like them to come back in a few hours and check the state of the system.

Basically I've got no idea how to do this with JSP.
But I guess the questions are 1)how can i get JSP to interact with an application that is running to get the results?
2)How can i get JSP to start an application running on the server without the user having to wait for the application to finish?

cheers guys
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JMS sounds like a good route. You could fire off a message to a listener which starts the app, add some code to the app which sends a message when its up and running (presuming you have an easy point when you know this). Then you could have a JSP which checks for the existance of this "I'm up and running" message on a Queue.
 
Tom Hill
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The application starts off some threads - atm the Threads are given a state telling me what they are doing.
I want to be able to get the JSP to return the values of the getState() method from the thread.

Is it legitamate to make the Thread a Staeful session bean, and collect the results through Remote interfaces? It seems slightly over the top though.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Those solutions sound a little OTT. If the thread state changes are relatively infrequent then why not just persist them in some way (DB/file) and write a simple JSP to display the persisted state?

In fact, if the worker threads are kicked off by the servlet you can keep a handle on them in the user's session, or perhaps better the servlet context in case the session goes missing.

Jules
 
Tom Hill
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought about the writing the state to a file/DB for each thread running - I thought that it was a bit of a hack for a solution though.

I'm not really from a JSP/Servlet background - I'm assuming that its possible to kick of some process (eg the thread) and then come back later and see what the thread is doing- much like a stateful session bean but with JSP?

I guess the question is: How do you go about resuming a Session with a JSP.
[ August 13, 2004: Message edited by: Tom Hill ]
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes (although my EJB knowledge is limited). Servlets are stateful so if you kick off the worker threads from the servlet it can maintain references to them for use by subsequent requests (e.g. from a JSP). This state can be exposed just to the session, i.e. the user that initiated the tasks, or to the application, i.e. to all users.

I'm not sure how it would work if you want/need daemon threads, i.e. how you would find them again if the app server was restarted...

Have a look at Sun's Servlet Fundamentals Tutorial and JSP Fundamentals Tutorial.

They're really pretty brief and should give you a good overview.

Jules
 
Tom Hill
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you can continue the session having a cookie on the browser that refers to the session object. What if you want to call up a session on another machine that doesnt have the cookie?
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that's partly why I suggested holding the state at the application level or persisting it. Assuming that you'll have some kind of user login you can store the user id against the state info, then any time the user logs in they'll be able to see the state of their jobs, no matter where they connect from.

Jules
 
Tom Hill
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahh haa - its all a lot clear now!
Thank you very much for you help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!