Hi
This is control flow.
ActionServlet-->Thread1-->Thread2
The thread2 is this.
public class NVTPrinter extends Thread {
PrintWriter out;
NVTInputStream inStream;
int j;
StringBuffer arr;
public NVTPrinter(NVTInputStream in, StringBuffer arr) {
super();
inStream = in;
this.arr=arr;
}
public void run() {
boolean finished = false;
try {
do {
int i = inStream.read();
if (i==-1) finished = true;
else {
if(((byte)i)!=((byte)255))
{
arr=arr.append((char)i);
}
yield();
}
}
while (!finished);
}
catch (IOException ex) {
System.out.println("NVTPrinter error");
}
catch(NullPointerException e)
{
System.out.println(""+e.toString());
}
}
}
Here is my Thread1
public Telnet2(String command,Socket sock,StringBuffer buf) {
this.command=command;
this.connection=sock;
this.buf=buf;
try {
outStream = new PrintStream(connection.getOutputStream());
inStream = new
NVTInputStream(connection.getInputStream(),outStream);
}
catch (IOException ex)
{
error ("IO error getting streams");
}
}
/*
* calls NVTPrinter for accepting the inputs
* runs the actual thread
*/
public void run()
{
printer = new NVTPrinter(inStream,buf);
printer.start();
yield();
outStream.println(command);
yield();
}
And here is my ActionServlet
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception {
String com2=((Pushlet2Form)form).getCom1();
Socket sock=(Socket)request.getSession().getAttribute("id");
StringBuffer
arrprint=(StringBuffer)request.getSession().getAttribute("str");
try {
Telnet2 tio=new Telnet2(com2,sock,arrprint);
tio.start();
Thread.sleep(1000);
String value=arrprint.toString();
((Pushlet2Form)form).setValue(value);
return mapping.findForward(FORWARD_lastpage);
}
catch(NullPointerException e)
{
return mapping.findForward(FORWARD_lastpage);
}
}
}
i think this is what u mentioned.and this may help you.