Problems with a Java socket client

Hi,
I'm using the following piece of code to recieve from a C++ server a string of chars:
TcpCli = new Socket(m_HostIP, m_HostPorta);
String msg="";
int lenSocketBuffer=0;
BufferedInputStream in = new BufferedInputStream(TcpCli.getInputStream());
lenSocketBuffer=in.available();
if (lenSocketBuffer > 0)
saveBuff = new byte[lenSocketBuffer];
in.read(saveBuff,0,lenSocketBuffer);
msg = saveBuff.toString();
I have verified that the creation of the Socket is OK (using debug on the Server side) and that the Server sends to the Client what I expect to receive. The length of the buffer read in lenSocketBuffer is OK but when I receive the buffer using in.read I find a string that is something like this: "[B@7b6889" which is a completely different buffer from what the server sends and much more shorter then the value of lenSocketBuffer.
Where is the problem? Please, help me.
Thank you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

replace...
msg = saveBuff.toString();
with...
msg = new String(saveBuff);
saveBuff.toString() returns the string-representation of the object saveBuff. new String(saveBuff) creates a new String-Object with the bytes of the given array.

Similar Messages

  • Having problems with a Java Telnet Client

    I'm trying to write a Telnet Client(for a mud). I've searched the forum but can't seem to find the answer to my problem. The mud sends the ANSI color codes, is there anyway to get java to interpret this, or will I have to make a parser and do all the work by hand?

    Try looking up RFC854 & RFC855. A Google Search will give several references. Other Searches include "Interpret As Command", and "Telnet IAC Options".
    The keys to telnet communications:
    1. Unless it is explicitly a command, it is data.
    2. All Commands start with the Interpret As Command (IAC) character, decimal 255 or hexidecimal ff.
    3. IAC DO/DONT/WILL/WONT Negotiations for a Telnet Option occurs before IAC SB/SE Subnegotiations. DON'T/WON'T is the default Telnet Network Virtual Terminal (NVT) setting for all options.
    4. All Negotiations complete before you get to the data phase.
    5. Be ready for Negotiations, at the start and during the middle of the Telnet Session....
    Here is an example of decoding Telnet
    The remote host may start with the following, shown in decimal:
    255, 253, 3, 255, 253, 24, etc...
    Viewed as UTF text, this appears to be some "y" characters with special accents above them.
    Cheat Sheet:
    255 == Interpret As Command (IAC)
    254 == DON'T, as is "I DON'T support xyz...."
    253 == DO, as in "I DO support xyz..."
    252 == WON'T, as in "You WON'T support abc..."
    251 == WILL, as in "You WILL support abc..."
    250 == SuBnegotiations Start (SB)
    240 == Subnegotiations End (SE)
    The above has 2 commands:
    - 255, 253, 3 == IAC DO Suppress Go Ahead
    - 255, 253, 24 == IAC DO Terminal Type
    Appropriate Responses could be:
    - 255, 251, 3, 255, 251, 24, etc....
    OR
    - 255, 252, 3, 255,252, 24, etc...
    OR
    - 255, 251, 3, 255, 252, 24, etc...
    OR
    - 255,252, 3, 255, 251,24, etc...
    Once you get the remotes questions answered, you can move on to the real work of passing data.
    Cheers,
    Joel.

  • Problems with games server and client

    Hi! I am making an MMORPG game and I have problems with the server and client connection.
    I can connect to the server, but when a second player does, the server console tells me this:
    java.net.SocketException: Connection reset
    After that, all clients disconnect.
    Which is the problem?
    How can I solve it?
    Thank you so much

    Here is how my sever work. I took some of this code from a book called Killer Programming Games in Java. If you google for it, you will find it for sure.
    TourGroup tg = new TourGroup(); // this object stores information about all clients connected to the server
        try {
          ServerSocket serverSock = new ServerSocket(PORT);
          Socket clientSock;
          while (true) {
            System.out.println("Waiting for a client...");
            clientSock = serverSock.accept();
            new TourServerHandler(clientSock, tg).start(); // this is the thread that monitors each client
        catch(Exception e)
        {  System.out.println(e);  }
      } This is some code of TourServerHandler
    public TourServerHandler(Socket s, TourGroup tg)
        this.tg = tg;
        clientSock = s;
        name= "?";
        cliAddr = clientSock.getInetAddress().getHostAddress();
        port = clientSock.getPort();
        System.out.println("Client connection from (" +
                     cliAddr + ", " + port + ")");
    public void run()
      // process messages from the client
        try {
          // Get I/O streams from the socket
          BufferedReader in  = new BufferedReader(
       new InputStreamReader( clientSock.getInputStream() ) );
          PrintWriter out =
    new PrintWriter( clientSock.getOutputStream(), true );  
    // and here goes the rest... The TourServerHandler thread uses this code to send messages:
    tg.broadcast(msg); tg.broadcast works like this:
    synchronized public void broadcast(String cliAddr, int port, String msg)
      // broadcast to everyone but original msg sender
        TouristInfo c; // this object stores info about the client
        for(int i=0; i < tourPeople.size(); i++) {
          c = (TouristInfo) tourPeople.get(i);
            c.sendMessage(msg);
      } This is the error part
    public void sendMessage(String msg)
      PrintWriter out;  
        out.println(msg);  
          System.out.println("OK");
      } I can't find any error but I still get that Connection reset exception...

  • Solution Manager systems RAM requirements - problems with the Java Engine

    Hello,
    I am about to install SAP Solution Manager 7 on a WIndows 2003 Server x64 but I need to know what the RAM requirements are? I have been having problems with the Java Engine starting and it seems to time out, I have heard that this is a very RAM hungry process and it might be why?
    Many thanks for your help in advance,
    Omar

    Hello Omar,
    To size SAP Solution Manager 7.0 EHP1 we recommend to use the SAP Solution Manager Quicksizer Tool at:
    http://service.sap.com/sizing-solman
    Here you find information on how to use the tool, how to collect input data for E2E Scenario Sizing, on SAP E2E RCA Sizing, Introscope Tuning, Wily Enterprise Manager Cluster Setup for E2E RCA Scenario and BI Aggregation Strategy in E2E Scenario.
    Please find more information about installing Solution Manager in:
    http://service.sap.com/instguides -> SAP Solution Manager
    I hope this information helps.
    Thanks,
    Mark

  • We have been having a problem with newsletters for a client. The newsletter works fine except if we add a button and/or link to the top zone on that newsletter it blows up ONLY ON iPhones!

    We have been having a problem with newsletters for a client.
    The newsletter works fine except if we add a button and/or link to the top zone on that newsletter it blows up ONLY ON iPhones!
    This happened last month too. It seems to be related to length of the newsletter too. It works on every device except iPhones - so weird.

    Hi, is anyone else experiencing i-phone only problems on email campaigns? not bashing Apple, just having issues where our newsletter are only having issues on iPhones

  • JCoIDoc IDocLibrary 3.0.2 Problems with IDocServerExample.java

    Hello, I´m facing a problem with IDocServerExample.java. I created a new project in eclipse, added the package com.sap.conn.idoc.examples and the class IDocServerExample.java. I configured the files "MYSERVER.jcoServer" and "BCE.jcoDestination" and started the application. Then I get the following error messages: *********************************************************************************************************************************************************
    com.sap.conn.jco.JCoException: (102) RFC_ERROR_COMMUNICATION: Unable to get repository at com.sap.conn.jco.rt.DefaultServer.update(DefaultServer.java:136) at com.sap.conn.jco.rt.DefaultServer.(DefaultServer.java:105) at com.sap.conn.idoc.jco.DefaultJCoIDocServer.(DefaultJCoIDocServer.java:35) at com.sap.conn.idoc.jco.DefaultJCoIDocServerFactory.createServer(DefaultJCoIDocServerFactory.java:17) at com.sap.conn.idoc.jco.DefaultJCoIDocServerFactory.createServer(DefaultJCoIDocServerFactory.java:13) at com.sap.conn.jco.rt.DefaultServerManager.getServer(DefaultServerManager.java:108) at com.sap.conn.jco.rt.StandaloneServerFactory.getServerInstance(StandaloneServerFactory.java:170) at com.sap.conn.idoc.jco.JCoIDoc.getServer(JCoIDoc.java:78) at com.sap.conn.idoc.examples.IDocServerExample.main(IDocServerExample.java:18) Caused by: com.sap.conn.jco.JCoException: (102) RFC_ERROR_COMMUNICATION: Connect to message server host failed Connection parameters: TYPE=B DEST=JCOSERVER01 MSHOST=arm115tx GROUP=PUBLIC R3NAME=T01 PCS=1 LOCATION CPIC (TCP/IP) on local host rz1462 with Unicode ERROR service '?' unknown TIME Tue Jul 07 09:09:40 200 RELEASE 711 COMPONENT NI (network interface) VERSION 39 RC -3 DETAIL NiErrSet COUNTER 2 at com.sap.conn.jco.rt.MiddlewareJavaRfc.generateJCoException(MiddlewareJavaRfc.java:615) at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcClient.connect(MiddlewareJavaRfc.java:1280) at com.sap.conn.jco.rt.ClientConnection.connect(ClientConnection.java:661) at com.sap.conn.jco.rt.PoolingFactory.init(PoolingFactory.java:103) at com.sap.conn.jco.rt.ConnectionManager.createFactory(ConnectionManager.java:171) at com.sap.conn.jco.rt.DefaultConnectionManager.createFactory(DefaultConnectionManager.java:44) at com.sap.conn.jco.rt.ConnectionManager.getFactory(ConnectionManager.java:160) at com.sap.conn.jco.rt.RfcDestination.initialize(RfcDestination.java:789) at com.sap.conn.jco.rt.RfcDestination.getSystemID(RfcDestination.java:817) at com.sap.conn.jco.rt.RepositoryManager.getRepository(RepositoryManager.java:32) at com.sap.conn.jco.rt.RfcDestination.getRepository(RfcDestination.java:891) at com.sap.conn.jco.rt.DefaultServer.update(DefaultServer.java:132) ... 8 more Caused by: RfcException: [null] message: Connect to message server host failed Connection parameters: TYPE=B DEST=JCOSERVER01 MSHOST=arm115tx GROUP=PUBLIC R3NAME=T01 PCS=1 LOCATION CPIC (TCP/IP) on local host rz1462 with Unicode ERROR service '?' unknown TIME Tue Jul 07 09:09:40 200 RELEASE 711 COMPONENT NI (network interface) VERSION 39 RC -3 DETAIL NiErrSet COUNTER 2 Return code: RFC_FAILURE(1) error group: 102 key: RFC_ERROR_COMMUNICATION at com.sap.conn.rfc.engine.RfcIoControl.error_end(RfcIoControl.java:255) at com.sap.conn.rfc.engine.RfcIoControl.ab_rfcopen(RfcIoControl.java:94) at com.sap.conn.rfc.api.RfcApi.RfcOpen(RfcApi.java:83) at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcClient.connect(MiddlewareJavaRfc.java:1273) ... 18 more
    Does anyone know what I´m doing wrong? With thanks, Veit

    Im having the same issue here.  Has anyone found a solution to this?

  • Performance problems with new Java Tiger style recommendations

    Performance problems with jdk 1.5 on Linux plattform
    (not tested on Windows, might be the same)
    using the new style recommendations.
    I need fast Vector loops for high speed mathematical calculations, some
    hints about the fastest way to program that loop would be also great!
    After refactoring using the new features from java 1.5 (as recommended from
    SUN) I lost performance significantly:
    using a vector:
    public Vector<unit> units;
    The new code (recommended from SUN for Java Tiger for redesign):
    for (unit u: units) u.accumulate();
    runs more than 30% slower than the old code:
    for (int i = 0; i < units.size(); i++) units.elementAt(i).accumulate();
    I expected the opposite.
    Is there any information available that helps?
    The following additional information I got from Mr. Shankar Unni:
    I got some fairly anomalous results comparing ArrayList and Vector: for the
    1.5-style loops, ArrayList was faster then Vector, but for a loop with get()
    calls, Vector was faster. Vector was even faster than that using
    elementAt(), which was a surprise:
    For a million summing iterations over a 100-element array:
    vector elementAt loop took 3446 ms.
    vector get loop took 3796 ms.
    vector iterator loop took 5469 ms.
    arraylist get loop took 4136 ms.
    arraylist iterator loop took 4668 ms.

    If your topic doesn't change, please stay in your original post.

  • Problems with a java bean in Weblogic 5.1

    Hello,
              I am having a problem deploying a java bean in Weblogic 5.1:
              I have been given a .class and a .jar file for a java bean (not an EJB). I
              placed the .class file into e:\temp\WEB-INF\classes and added the following
              line to my weblogic.properties file:
              weblogic.httpd.webApp.testApp=e:/temp/
              I have also updated the web.xml file in the WEB-INF directory as follows:
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
              Application 1.2//EN"
              "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
              <web-app>
              <servlet>
              <servlet-name>EdIface</servlet-name>
              <jsp-file>test.jsp</jsp-file>
              </servlet>
              <servlet-mapping>
              <servlet-name>EdIface</servlet-name>
              <url-pattern>EdIface</url-pattern>
              </servlet-mapping>
              </web-app>
              When I try to access my http:\\server:port\testApp\test I get an "Error
              500 - internal server error".
              Has anyone had experice with deploying a java bean with jsut the .class and
              .jar file? Where should I put the .jar file?
              I appreciate any advice!
              

    Bump

  • A problem with my Java Scrabble game

    Hello
    I am making a Java Scrabble game for a school assignment and I have a problem with the following:
    The number of players is input by the user (2 to 4) and i need to create a number of arrays based on the number of players. These arrays must have 7 playing pieces at all times until the "bag" of pieces has less pieces than those required to replace the ones a certain player just used (in wich case the bag would give that player all of it's remaining pieces and, from this point on, the player arrays would not necessarily need to have 7 pieces).
    this is my procedure to take a piece from the bag:
         public Piece takePiece()
              if (this.pieceCounter > 0) {
                   Arrays.sort(this.pieces, 0, this.pieceCounter);
                   int i = this.generator.nextInt(this.pieceCounter);
                   Piece p = this.pieces;
                   this.pieceCounter--;
                   this.pieces[i] = this.pieces[this.pieceCounter];
                   return p;
              else
                   return null;
    this is my Piece class:
    public class Piece implements Comparable {
         private int scorePiece;
         private char letterPiece;
         public Piece(char letterPiece, int scorePiece)
              this.scorePiece = scorePiece;
              this.letterPiece = letterPiece;
         public int scorePiece()
              return scorePiece;
         public String letterPiece()
              return letterPiece();
         public String toString()
              return letterPiece+ " " + scorePiece;
         public int compareTo(Object a)
              Piece piece= (Piece) a;
              return (int) letterPiece - (int) piece.letterPiece;
    }Thanks in advance for your help

    Ok, if i create a Players class and do this in Main class:
         if(nPlayers >= 2 && nPlayers <= 4)
              Players arrayPlayers[];
              arrayPlayers= new Players [nPlayers ];
              for(int i=0 ; i < nPlayers ; i++)
                       arrayPlayers[i] = new Players ();
              }My Players Class should contain something like this:
             // Array of 7 that contains Pieces...
         Piece[] pieces= new Piece[7];how can i get pieces from takePiece(); (Class Bag) and put them in the pieces arrays until takePiece(); returns null?

  • Problems with VA Java Visual Composition

    Hi!
    I have some problems with reopening (even simple) visually in VA Java created
    beans (JFrame, JDialog). IDE behaves somehow unpredictable. Sometimes it reopened it into the
    visual composition editor, anothe time the reoppening fails with following log message:
    Java exception during layout of bean(<unnamed>): java.lang.NullPointerException
    Java exception during layout of bean(JFrameContentPane): java.lang.NullPointerException
    An exception occurred in a system program.
    Terminating TimeSlotGUI (VCE) (System) (25/07/01 10:05:07)
    Can anybody help?
    Ivan

    Which Version do you use? This VAJ 3.5 was quite bugy and you had to use patches. Now there is an Update 3.5.2 which fixes most of the bugs ( although there are new ones). When I work with the VCE ( avoid this normally) I get problems if I rename Beans which were generated with th VCE. then your stuff is lost. Sometimes you can recover if you delete the generated[i] initialize() method and then open the VCE.
    Nevertheless, VAJ 3.5.3 works quite good, great debugging tools.

  • Printer Problems with 10.5.8 Clients

    I have a problem with my printer settings since we upgraded to 10.5.8. They seem not to be reading the drivers aswell as they did. Several of the page setup options have either disappeared or ceased to function. I have three print queues on my network but the most problematic is my A3 colour laser, a Ricoh Aficio CL700PS. I have checked we have the latest driver.
    As a network user I can't even select A3 as an option but as a local user I can but it just prints to A4 but cropped. This never happened to my 10.4.11 clients who happily printed any size paper.
    I have checked the server which is 10.5.7 and that prints fine when logged in as an admin account. WGM picked the print server settings off the server and all the machines have the same drivers on them. Any ideas because I'm baffled!

    10.5.3

  • Problem with users disabling ARD client service

    I've got a problem and i'm not quite sure of the work around. I'm a PC guy by nature and can't quite figure this out.
    I'm having a problem with users disabling the ARD service from the sharing menu. Unfortunately users need to have admin privleges to do their work so I can't simply give them a standard account.
    I've hidden the ARD user account i created from the login window through Netinfo, but I need to find a way to stop users from shutting the ard service down.
    They don't seem to understand that the company requires that it be on the computer. Now, I'm the one who is set as the admin for ARD in the building, however we really just use it to rollout drivers, install packages, and its a lifesaver for remotely fixing problems with programs. The company didn't really buy it to spy on the employee's.
    Is there any way to hide the service from an admin level account? Or keep them from shutting it down?
    BTW, this would have to be done on multiple machines running both panther and tiger.
    Any help would be appreciated as I'm not quite sure where to start.

    First, as a matter of policy, let them know this service is active, and needs to remain active. If they disobey this instruction and turn it off, you have a human resources issue, not a technical issue.
    Second, there are very few enterprise users that need admin access to their machines. Oh, they ALL think they do, and there will be howling when non-admin status is first imposed, but we have 350 users in a publishing environment with less that 20 setup as admins. Those users are almost all superusers who assist others in a technical role.
    We have far fewer software problems like this and with ARD, IT can install/ authorize installation of software remotely should a user need that. It simply does not dramatically impact our users to have non-admin access. On the other hand, we recognize that a FEW users will need more access, and grant that on a case-by-case basis.

  • HT5559 I  can't connecting  to chat  please can you help me,i think my problem with da java

    I  can't connecting  to chat  please can you help me,i think my problem with da java

    Have you read thread (From More like this on the right)
    https://discussions.apple.com/message/18837278#18837278

  • Problem with Sun Java Creator JDBC driver .....

    Hi:
    I am new to Java Studio Creator. I am using Oracle Enterprise Edition 8.0.5.0 database to get data from. Through Servers Navigator->Data Sources, I define a new datasource using default JSC JDBC driver for Oracle. However, when I try to test the connection I get the following error.
    [sunm][Oracle JDBC Driver] Internal Error: Net8 Protocol Error
    Can someone tell me what is going on here? By the way I also have Netbeans 4.0 IDE which works fine with the same database.
    -Victor bagga

    I was using the following database URL.
    jdbc:sun:oracle://autoserv.cqtel.com:1521;SID=autosvdb
    The SID is valid because I can use other JDBC drivers such as Oracle's thin driver which uses the Database URL
    jdbc:oracle:thin:@autoserv.cqtel.com:1521:autosvdb
    and it works. However, I can not use the Oracle thin JDBC driver with Sun Java Creator as it seems to be incompatible. Using this driver I can successfully define a datasource and veiw all the data and make all kind of queries through the Server Navigator window but when I try to drop a database table on to a Data Table in my project, nothing happens. If I try to Edit the query on the rowset, the GUI window does not show any Column names and display names.
    By the way, I also have an Oracle 9.x database which works just fine with Java Ctreator Studio. I really like Java Creator as I find it very productive but not being able to make it work with Oracle 8.0.5.0 takes the fun out of it.

  • Problems with "SecondMidletServlet.java"

    Hi guys, I'm now trying to use MIDlet to connnect a servlet which will retrieve the data from MS Access database.
    I had tried the sample programs(First & SecondMidletServlet) in this site. It's fine for me to run the "FirstMidletServlet.java"... but I need the more advance method - POST. When I run "SecondMidletServlet.java", the MIDlet program is stopped after I click the 'submit' button where the program asking me "Is it OK to use airtime?"... Even i choose 'Yes', it doesn't work..
    Do anyone could help? Please kindly tell me what's the problem behind.... Thanks!!!

    Yes, here it's:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.io.*;
    * An example MIDlet with simple "Hello" text and an Exit command.
    * Refer to the startApp, pauseApp, and destroyApp
    * methods so see how each handles the requested transition.
    * @author  Ken_2
    * @version
    public class GetNpost extends MIDlet implements CommandListener {
        private Display display;    // The display for this MIDlet
        private Form fmMain;
        private Alert alError;
        private Command cmGET;
        private Command cmPOST;
        private Command cmExit;   // The exit command
        private TextField tfAcct;
        private TextField tfPwd;
        private StringItem siBalance;
        private String errorMsg = null;
        public GetNpost() {
            display = Display.getDisplay(this);
            //Create Command
            cmGET = new Command ("GET", Command.SCREEN, 2);
            cmPOST = new Command ("POST", Command.SCREEN, 3);
            cmExit = new Command("Exit", Command.SCREEN, 1);
            // Textfields
            tfAcct = new TextField("Account:",  "", 5,  TextField.NUMERIC);
            tfPwd = new TextField("Password:", "", 10,  TextField.ANY | TextField.PASSWORD);
            //Balance string item
            siBalance = new StringItem("Balance: $","");
            // Create Form, add commands & Components, listen for events
            fmMain = new Form("Account Information");
            fmMain.addCommand(cmExit);
            fmMain.addCommand(cmGET);
            fmMain.addCommand(cmPOST);
            fmMain.append(tfAcct);
            fmMain.append(tfPwd);
            fmMain.append(siBalance);
            fmMain.setCommandListener(this);
         * Start up the Hello MIDlet by creating the TextBox and associating
         * the exit command and listener.
        public void startApp() {  
            display.setCurrent(fmMain);
         * Pause is a no-op since there are no background activities or
         * record stores that need to be closed.
        public void pauseApp() {
         * Destroy must cleanup everything not handled by the garbage collector.
         * In this case there is nothing to cleanup.
        public void destroyApp(boolean unconditional) {
         * Respond to commands, including exit
         * On the exit command, cleanup and notify that the MIDlet has been destroyed.
        public void commandAction(Command c, Displayable s) {
            if (c == cmGET || c == cmPOST) {
                try
                    if (c == cmGET)
                        lookupBalance_withGET();
                    else
                        lookupBalance_withPOST();
                catch (Exception e)
                    System.err.println("Msg: " + e.toString());
            else if (c == cmExit)
                destroyApp(false);
                notifyDestroyed();
         * Access servlet using GET
        private void lookupBalance_withGET() throws IOException
            HttpConnection http = null;
            InputStream iStrm = null;
            boolean ret = false;
            // Data is passed at the end of url for GET
            String url = "http://ismt.no-ip.com/servlet/DRMfypGroup2.GetNpostServlet" + "?" + "account=" + tfAcct.getString() + "&" + "password=" + tfPwd.getString();
            try
                http = (HttpConnection) Connector.open(url);
                // Client Request
                //  1) Send request method
                http.setRequestMethod(HttpConnection.GET);
                //  2) Send header information - none
                //  3) Send boday/data - data is at the end of URL
                //  Server Response
                iStrm = http.openInputStream();
                // Three steps are processed in this method call
                ret = processServerResponse( http, iStrm);
            finally
                // Clean up
                if (iStrm != null)
                    iStrm.close();
                if (http != null)
                    http.close();
            // Process request failed, show alert
            if (ret == false)
                showAlert(errorMsg);
         * Access servlet using POST
        private void lookupBalance_withPOST() throws IOException
            HttpConnection http = null;
            OutputStream oStrm = null;
            InputStream iStrm = null;
            boolean ret = false;
            // Data is passed at the end of url for GET
            String url = "http://ismt.no-ip.com/servlet/DRMfypGroup2.GetNpostServlet" + "?" + "account=" + tfAcct.getString() + "&" + "password=" + tfPwd.getString();
            try
                http = (HttpConnection) Connector.open(url);
                oStrm = http.openOutputStream();
                // Client Request
                //  1) Send request method
                http.setRequestMethod(HttpConnection.POST);
                //  2) Send header information. Required for POST to work!
                http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                // If you experience connectoin/IO problems, try removing the comment from the following line
                //http.serRequestProperty("Connection", "clsoe");
                //  3) Send boday/data
                // Write account number
                byte data[] = ("account=" + tfAcct.getString()).getBytes();
                oStrm.write(data);
                oStrm.flush();
                //  Server Response
                iStrm = http.openInputStream();
                // Three steps are processed in this method call
                ret = processServerResponse(http, iStrm);
            finally
                // Clean up
                if (iStrm != null)
                    iStrm.close();
                if (http != null)
                    http.close();
            // Process request failed, show alert
            if (ret == false)
                showAlert(errorMsg);
         * Process a response from a server
        private boolean processServerResponse(HttpConnection http, InputStream iStrm) throws IOException
            // Reset  error message
            errorMsg = null;
            //  1) Get Statis Line
            if (http.getResponseCode() == HttpConnection.HTTP_OK)
                //  2) Get header information - none
                //  3) Get body (data)
                int length = (int) http.getLength();
                String str;
               if (length != -1)
                   byte servletData[] = new byte[length];
                   iStrm.read(servletData);
                   str = new String(servletData);
               else  // Length not available...
                   ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
                   int ch;
                   while ( (ch =iStrm.read()) != -1)
                       bStrm.write(ch);
                   str = new String (bStrm.toByteArray());
                   bStrm.close();
                //Update the string item on the display
                siBalance.setText(str);
                return true;
            else
                // Use message from the servlet
                errorMsg = new String ( http.getResponseMessage() );
            return false;
         * Show an alert
        private void showAlert(String msg)
            // Create Alert, use message returned from servlet
            alError = new Alert("Error", msg, null, AlertType.ERROR);
            // Set Alert to type model
            alError.setTimeout(Alert.FOREVER);
            // Display the Alert. Once dismissed, display the form
            display.setCurrent( alError, fmMain);
    }Thanks!!!

Maybe you are looking for

  • Video adapter only works for slide shows.

    We received the Apple video adapter today. It appears that it only works for slide shows? It might also work for Keynote, but we don't use that much and haven't installed on the iPad. For our purposes, we'd like to be able to display from other progr

  • Godaddy is showing that the businesscatayst has been redirected correctly but when i link to remote from dreaweaver it shows a ftp error

    dreamweaver connects to server correctly, godly is showing my business catalyst site has been redirected correctly but when i access remote from dreamweaver it says there is a ftp error. How do i resolve this

  • Other language  getURL issue

    Hi, Using ActionScript 2.0 Flash CS3. I want to navigate to a foreign language URL which comes from an XML. XML is in UTF -8 format. After loading the XML, i used trace() statement to check the URL is correct. No problem in that. Successfully navigat

  • Fireworks CS6 Freezing On Loading Keyboard Shortcuts

    For the past two days, whenever I try to start Adobe Fireworks CS6, the Splash menu freezes on "Initializing Keyboard Shortcuts". I have tried resetting the preferences and the program still freezes. I have uninstalled and reinstalled the program sev

  • Calling transaction FB50

    HI I want to call transaction each time with a different Document Type is it posible? i tried to set parameter id 'BAR' field 'SS' and than call transaction 'FB50' or doing batch input , but it didnt work! , when i used call transaction i got documen