• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

Job Running status - webapplication with struts

Hi,

I have the following situation in my webapplication. I have a webpage and i have some defined links in the page. The purpose of each link is to call a stored procedure in the background. I mean to say, i opened up a new thread and don't wait for the completion of the stored procedure. But the problem i m facing is, if a user press the link and the process is already running..i want to display a information page with the message that the process is already running.

As i started the calling of the process in a new thread. I can't really check the exception.
               
               JobExecutionThread jth = new JobExecutionThread(name);
                new Thread(jth).start();

How can check the status of the running process (status in "finished" OR "Running") ?

Please advice.
aks
0
aks143
Asked:
aks143
  • 3
  • 2
1 Solution
 
objectsCommented:
Add methods to yout JobExecutionThread class that return its status.
And store jth in the session so subsequent requests can access it.
0
 
aks143Author Commented:
Hi objects,

thanks for the reply. But i didn't ur point very clearly...how can i set the status in a thread (i m new to thread programming). For example..

My thread looks like the folloing..

    public synchronized void run() {

        logger.debug("The job name " + name);

        try {
          // making a connection and calling the stored procedure            
        } catch (SQLException e) {
          // catching exception
        } finally {
         // clean up
        }
    }
 
and my thread "jth" -- setting in the session???

Can you just give some sample code of ur explanation?
thanks
aks
0
 
objectsCommented:
something like:


    private boolean running = false;

    public boolean isRunning()
    {
       return running;
    }

    public synchronized void run() {
        running = true;
        logger.debug("The job name " + name);

        try {
          // making a connection and calling the stored procedure            
        } catch (SQLException e) {
          // catching exception
        } finally {
         // clean up
         running = false;
        }
    }
0
 
objectsCommented:
> and my thread "jth" -- setting in the session???

session.setAttribute("running", jth);

0
 
aks143Author Commented:
Hi objects,

thanks for your help. It does the trick.

regards
aks
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now