I am using Jsp and servlets. In one of my jsp page I will call a .sh file which will execute for 2-3 minutes and after the process is completed It will redirect to another jsp page. My problem is the user has to wait for 2-3 mins and then after the process completion only he is re-directed to the next page. I don't want this to happen I want to start that process which must run in background and I want the page to be redirected immediatly.
process.jsp page
FileWriter fileWriter = new FileWriter(file3,true);
BufferedWriter bufferFileWriter = new BufferedWriter(fileWriter);
fileWriter.append(userid+"\t"+movie_id[i]+"\t"+ratings[i]);
fileWriter.append('\n');
bufferFileWriter.close();
Process p=Runtime.getRuntime().exec("/home/yoganandhd/project.sh");
p.waitFor();
response.sendRedirect("login.jsp");
In the above code, to execute project.sh it will take 3 mins where it will do some datamining process and then only it is getting redirected to the login.jsp page. My requirement is the user cannot wait for 3 mins, he must be redirected to the next page immediatly by running the project.sh at the background.
I am a fresher I dont know much about java can anyone say how can I acheive this? Can I acheive this using thread? If yes how? Someone please explain me with an example of same scenario.