Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Missing characters

Thread view: 
raavi - 31 Jan 2006 08:55 GMT
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.
Alan Krueger - 31 Jan 2006 16:25 GMT
> Hi all
>     I am now involved in a telnet application.i am reading the stream
[quoted text clipped - 6 lines]
> 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?
raavi - 01 Feb 2006 06:35 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.