Missing characters

R

raavi

Hi all
I am now involved in a telnet application.i am reading the stream
as integer and converting it into byte.then i am assigning the
character conversion to some sttring buffer.when i am using terminal to
provide user input it is working fine.but the problem i am facing is
that here i am using struts framework and the inputs are given through
jsp page there are missing characters in the output.actually the
program is a multi threaded one and threads are slept to get the
result.can anyone have any idea? if so please do tell me. Thanks in
advance.
 
A

Alan Krueger

raavi said:
Hi all
I am now involved in a telnet application.i am reading the stream
as integer and converting it into byte.then i am assigning the
character conversion to some sttring buffer.when i am using terminal to
provide user input it is working fine.but the problem i am facing is
that here i am using struts framework and the inputs are given through
jsp page there are missing characters in the output.actually the
program is a multi threaded one and threads are slept to get the
result.can anyone have any idea? if so please do tell me. Thanks in
advance.

Maybe you should post a bit of code that demonstrates what you're
talking about?
 
R

raavi

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,159
Latest member
SweetCalmCBDGummies
Top