Hi
I am writing a JSP tag that will basically execute certain tasks and update the status in JSP page after completion of each task.
Lets take below example -
I want to verify different softwares like Tomcat/MySql/Java... before doing some operation. In my index.jsp page when I will click on button "Start Verification" at back end the custom tag will keep on verifying the softwares and display the status in same jsp page (which is already loaded)
Below is my tag support class - when its executing below highlighted line, throw error - Stream is closed.
Is there any way to create a separate thread in JSP custom tag ?
@Override
public void doTag() throws JspException
{
try
{
Thread thread = new Thread(new RecoveryLoggerThread(),"RecoveryLoggerThread");
thread.start();
}
catch (Exception e)
{
e.printStackTrace();
}
//return SKIP_BODY;
}
class RecoveryLoggerThread implements Runnable
{
@Override
public void run()
{
try
{
PageContext pageContext = (PageContext) getJspContext();
JspWriter out = pageContext.getOut();
out.println(getLogData("Tomcat", false) +"\t\t");
out.println("OK");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}