HttpConnection in CLDC1.0

Hi,
I've made a midlet that connects to an URL thru GPRS,
it works perfect in CLDC1.1 but when I try it in CLDC1.0
it keeps trying to connect and do nothing then....
not even an exception or error... nor Timeout is thrown
is there something special to do in cldc1.0??

this is my resumed code:
public class LoginStream extends Thread {
    HttpConnection conn = null;
    DataInputStream hdin = null;
    DataOutputStream hdout = null;
   private void connect() {
        try {
            // ALERT 1: display an alert with LOADING... in written
            conn = (HttpConnection) Connector.open(SystemConstants.URL_LOGIN, Connector.READ_WRITE, true);
            conn.setRequestMethod(HttpConnection.POST);
            hdout = conn.openDataOutputStream();
            if(hdout != null)
                configureOutputStream(); // sets the write methods....
            hdout.flush();
            hdout.close();
            hdin = conn.openDataInputStream();
            String token = hdin.readUTF();
            hdin.close();
        try {
             // system code....
        } catch(Error e) {
            e.printStackTrace();
            // show an alert
        } catch(Exception e) {
            e.printStackTrace();
           // shows an alert
            try {
                Thread.sleep(2000);
            }catch(InterruptedException ie) {
                // shows alert
            if(!conectou) {
                // go to the next form, login passed   
        } finally {
            try {
                if(null != conn)
                    conn.close();
            } catch(IOException ioe) {
                ioe.printStackTrace();
    public void run() {
        connect();
}

Similar Messages

  • Problem with HttpConnection.....Its Urgent

    hi guys
    i m new to this forum.I read many thread in this forum but unable to get the answaer for my problem.
    I m developing application to get the data from the server ,i used Httpconnection for that.Its works fine for maximum 10 minutes on Nokia 60 series emulator baut after that its showas an error message"unable to establish the connection" and 9500 nokia communicator is hang .
    Can any one help me solve this issue ?is there any problem with the Cache Memory or is it due to some other reason.
    Thanks In Advance

    hello,
    i am a quite new comer.
    i tried to establish a network connection with the server from the KToolbar, but an exception named:
    /* error msg
    Exception: java.io.IOException: Error initializing
    HTTP tunnel connection:
    HTTP/1.0 403 Forbidden
    Server: squid/2.5.STABLE1
    Mime-Version: 1.0
    Data: Sun, 28 May 2006 13:00:28 GMT
    Content-Type: text/html
    ContentLength: 1056
    Expires: Sun,28 May 2006 13:00:28 GMT
    X-Squid-Error: ERR_ACCESS_DENIED 0
    X-Cache: MISS from gw03.univdhaka.edu
    Proxy-Connection: close
    had thrown.
    my used code is:
    // HTTPMIDlet.java
    import java.io.*;
    import javax.microedition.io.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class HTTPMIDlet extends MIDlet implements CommandListener, Runnable
         private Display mDisplay;
         private Form mMainScreen;
         public HTTPMIDlet()
              mMainScreen = new Form( "HTTPMIDlet" );
              mMainScreen.append( "Press OK to create an HTTP connection." );
              Command exitCommand = new Command( "Exit", Command.EXIT, 0 );
              Command okCommand = new Command( "OK", Command.OK, 0 );
              mMainScreen.addCommand( exitCommand );
              mMainScreen.addCommand( okCommand );
              mMainScreen.setCommandListener( this );
         public void startApp()
              if( mDisplay==null )
              mDisplay = Display.getDisplay( this );
              mDisplay.setCurrent( mMainScreen );
         public void pauseApp()
         public void destroyApp( boolean unconditional )
         // CommandListener method
         public void commandAction( Command c, Displayable s )
              if( c.getCommandType()==Command.EXIT )
                   notifyDestroyed();
              else if( c.getCommandType()==Command.BACK )
                   mDisplay.setCurrent( mMainScreen );
              else if( c.getCommandType()==Command.OK )
                   // Put up a wait screen.
                   Form waitForm = new Form( "Connecting..." );
                   mDisplay.setCurrent( waitForm );
                   // Make the connection
                   Thread t = new Thread( this );
                   t.start();
         // Runnable method
         public void run()
              //String url = "http://wireless.java.sun.com/";
              String url = "http://203.112.196.113/";
              Form resultsForm = new Form( "Results" );
              Command backCommand = new Command( "Back", Command.BACK, 0 );
              resultsForm.addCommand( backCommand );
              resultsForm.setCommandListener( this );
              HttpConnection hc = null;
              InputStream in = null;
              try
                   // Now make a connection to the server.
                   hc = ( HttpConnection )Connector.open( url );
                   if( hc==null )
                   {System.out.println( "HTTP not Connected..." );}
                   // Retrieve the response.
                   in = hc.openInputStream();
                   int length = 256;
                   byte[] raw = new byte[length];
                   int readLength = in.read( raw );
                   String message = new String( raw, 0, readLength );
                   resultsForm.append( message );
              catch( Exception e )
                   resultsForm.append( new StringItem( "Exception: ", e.toString() ) );
              finally
                   if( in!=null )
                        try
                             in.close();
                        catch( IOException ioe )
                   if( hc!=null )
                        try
                             hc.close();
                        catch( IOException ioe )
              mDisplay.setCurrent( resultsForm );
    }pls, help me with some code or cofiguration guide, if necessary.
    i am now completely stuck at this point, coz without network connection i can't proceed.
    i mailed u, as i seen that u already establish a network connection. so pls pls pls help me......
    info:
    OS: WinXP
    API: MIDP2.0, CLDC1.1
    Server: proxy.univdhaka.edu (linux OS)
    thanx in advance...
    bye...

  • Nokia 40Series & HTTPconnection

    hi there people ....
    am facing a wierd problem with nokia 40 series mobiles ....
    i've build a cldc1.0 and MIDP 2.0 mobile application that got an http connection ...
    my application works as the following ... it initiate an http connection a recives data and show it on the screen ..... ?
    i've tested my appliations on several emulators and devices ... but in the nokia 40 series it works but the http connection gets no data and it doesn't retrive data at all ....
    here is the method i use for my http connection ......" note the 4o series only uses WAP gateway"
    private String requestUsingGET(String URL) throws IOException{
    s1=" ";
    HttpConnection c = null;
    OutputStream os = null;
    InputStream is = null;
    StringBuffer b = new StringBuffer();
    String request = HttpConnection.POST;
    TextBox t = null;
    try {
    long len = -1;
    int ch = 0;
    long count = 0;
    int rc;
    c = (HttpConnection)Connector.open(URL);
    c.setRequestMethod(request);
    c.setRequestProperty("foldedField",
    "first line\r\n second line\r\n third line");
    if (request == HttpConnection.POST) {
    String m = "Test POST text.";
    os = c.openOutputStream();
    os.write(m.getBytes());
    os.close();
    rc = c.getResponseCode();
    if (rc != HttpConnection.HTTP_OK) {
    b.append("Response Code: " + c.getResponseCode() + "\n");
    b.append("Response Message: " + c.getResponseMessage() +
    "\n\n");
    is = c.openInputStream();
    if (c instanceof HttpConnection) {
    len = ((HttpConnection)c).getLength();
    if (len != -1) {
    // Read exactly Content-Length bytes
    for (int i = 0; i < len; i++) {
    if ((ch = is.read()) != -1) {
    if (ch <= ' ') {
    ch = ' ';
    b.append((char) ch);
    count ++;
    if (count > 200) {
    break;
    } else {
    byte data[] = new byte[100];
    int n = is.read(data, 0, data.length);
    for (int i = 0; i < n; i++) {
    ch = data[i] & 0x000000ff;
    b.append((char)ch);
    try {
    if (is != null) {
    is.close();
    if (c != null) {
    c.close();
    } catch (Exception ce) {
         try {
              len = is.available();
         } catch (IOException io) {
    io.printStackTrace();
         // Test to make sure available() is only valid while          // the connection is still open.
    s1 =b.toString();
    t = new TextBox("Http Test", b.toString(), b.length(), 0);
    is = null;
    c = null;
    } catch (IOException ex) {
    ex.printStackTrace();
    if (c != null) {
    try {
    String s = null;
    if (c instanceof HttpConnection) {
    s = ((HttpConnection)c).getResponseMessage();
    if (s == null){
    s = "No Response message";
    s1=s;
    t = new TextBox("Http Error", s, s.length(), 0);
    } catch (IOException e) {
    e.printStackTrace();
    String s = e.toString();
    if (s == null){
    s = ex.getClass().getName();
    s1 =s;
    t = new TextBox("Http Error", s, s.length(), 0);
    try {
    c.close();
    } catch (IOException ioe) {
    // do not over throw current exception
    } else {
    t = new TextBox("Http Error", "Could not open URL", 128, 0);
    } catch (IllegalArgumentException ille) {
    // Check if an invalid proxy web server was detected.
    t = new TextBox("Illegal Argument",
    ille.getMessage(), 128, 0);
    if (is != null) {
    try {
    is.close();
    } catch (Exception ce) {; }
    if (c != null) {
    try {
    c.close();
    } catch (Exception ce) {; }
    return (s1);
    }

    not all network services allow user programs to open HTTP connections so check with the network operator to confirm Whether HTTP connections are allowed.

  • Need help with my HttpConnection From Midlet To Servlet...

    NEED HELP ASAP PLEASE....
    This class is supposed to download a file from the servlet...
    the filename is given by the midlet... and the servlet will return the file in bytes...
    everything is ok in emulator...
    but in nokia n70... error occurs...
    Http Version Mismatch shows up... when the pout.flush(); is called.. but when removed... java.io.IOException: -36 occurs...
    also i have posted the same problem in nokia forums..
    please check also...
    http://discussion.forum.nokia.com/forum/showthread.php?t=105567
    now here are my codes...
    midlet side... without pout.flush();
    public class DownloadFile {
        private GmailMidlet midlet;
        private HttpConnection hc;
        private byte[] fileData;
        private boolean downloaded;
        private int lineNumber;
    //    private String url = "http://121.97.220.162:8084/ProxyServer/DownloadFileServlet";
        private String url = "http://121.97.221.183:8084/ProxyServer/DownloadFileServlet";
    //    private String url = "http://121.97.221.183:8084/ProxyServer/Attachments/mark.ramos222/GmailId111d822a8bd6f6bb/01032007066.jpg";
        /** Creates a new instance of DownloadFile */
        public DownloadFile(GmailMidlet midlet, String fileName) throws OutOfMemoryError, IOException {
            System.gc();
            setHc(null);
            OutputStream out = null;
            DataInputStream is= null;
            try{
                setHc((HttpConnection)Connector.open(getUrl(), Connector.READ_WRITE));
            } catch(ConnectionNotFoundException ex){
                setHc(null);
            } catch(IOException ioex){
                ioex.printStackTrace();
                midlet.alertScreen = new AlertScreen("Error C1", ioex.toString(),
                        null, AlertType.ERROR);
                midlet.alertScreen.setTimeout(Alert.FOREVER);
                midlet.display.setCurrent(midlet.alertScreen);
            try {
                if(getHc() != null){
                    getHc().setRequestMethod(HttpConnection.POST);
                    getHc().setRequestProperty("Accept","*/*");
                    getHc().setRequestProperty("Http-version","HTTP/1.1");
                    lineNumber = 1;
                    getHc().setRequestProperty("CONTENT-TYPE",
                            "text/plain");
                    lineNumber = 2;
                    getHc().setRequestProperty("User-Agent",
                            "Profile/MIDP-2.0 Configuration/CLDC-1.1");
                    lineNumber =3;
                    out = getHc().openOutputStream();
                    lineNumber = 4;
                    PrintStream pout = new PrintStream(out);
                    lineNumber = 5;
                    pout.println(fileName);
                    lineNumber = 6;
    //                pout.flush();
                    System.out.println("File Name: "+fileName);
                    lineNumber = 7;
                    is = getHc().openDataInputStream();
                    long len = getHc().getLength();
                    lineNumber = 8;
                    byte temp[] = new byte[(int)len];
                    lineNumber = 9;
                    System.out.println("len "+len);
                    is.readFully(temp,0,(int)len);
                    lineNumber = 10;
                    setFileData(temp);
                    lineNumber = 11;
                    is.close();
                    lineNumber = 12;
                    if(getFileData() != null)
                        setDownloaded(true);
                    else
                        setDownloaded(false);
                    System.out.println("Length : "+temp.length);
                    midlet.setAttachFile(getFileData());
                    lineNumber = 13;
                    pout.close();
                    lineNumber = 14;
                    out.close();
                    lineNumber = 15;
                    getHc().close();
            } catch(Exception ex){
                setDownloaded(false);
                ex.printStackTrace();
                midlet.alertScreen = new AlertScreen("Error C2+ line"+lineNumber,
                        ex.toString()+
                        " | ",
                        null, AlertType.ERROR);
                midlet.alertScreen.setTimeout(Alert.FOREVER);
                midlet.display.setCurrent(midlet.alertScreen);
        public HttpConnection getHc() {
            return hc;
        public void setHc(HttpConnection hc) {
            this.hc = hc;
        public String getUrl() {
            return url;
        public void setUrl(String url) {
            this.url = url;
        public byte[] getFileData() {
            return fileData;
        public void setFileData(byte[] fileData) {
            this.fileData = fileData;
        public boolean isDownloaded() {
            return downloaded;
        public void setDownloaded(boolean downloaded) {
            this.downloaded = downloaded;
    }this is the midlet side with pout.flush();
    showing Http Version Mismatch
    public class DownloadFile {
        private GmailMidlet midlet;
        private HttpConnection hc;
        private byte[] fileData;
        private boolean downloaded;
        private int lineNumber;
    //    private String url = "http://121.97.220.162:8084/ProxyServer/DownloadFileServlet";
        private String url = "http://121.97.221.183:8084/ProxyServer/DownloadFileServlet";
    //    private String url = "http://121.97.221.183:8084/ProxyServer/Attachments/mark.ramos222/GmailId111d822a8bd6f6bb/01032007066.jpg";
        /** Creates a new instance of DownloadFile */
        public DownloadFile(GmailMidlet midlet, String fileName) throws OutOfMemoryError, IOException {
            System.gc();
            setHc(null);
            OutputStream out = null;
            DataInputStream is= null;
            try{
                setHc((HttpConnection)Connector.open(getUrl(), Connector.READ_WRITE));
            } catch(ConnectionNotFoundException ex){
                setHc(null);
            } catch(IOException ioex){
                ioex.printStackTrace();
                midlet.alertScreen = new AlertScreen("Error C1", ioex.toString(),
                        null, AlertType.ERROR);
                midlet.alertScreen.setTimeout(Alert.FOREVER);
                midlet.display.setCurrent(midlet.alertScreen);
            try {
                if(getHc() != null){
                    getHc().setRequestMethod(HttpConnection.POST);
                    getHc().setRequestProperty("Accept","*/*");
                    getHc().setRequestProperty("Http-version","HTTP/1.1");
                    lineNumber = 1;
                    getHc().setRequestProperty("CONTENT-TYPE",
                            "text/plain");
                    lineNumber = 2;
                    getHc().setRequestProperty("User-Agent",
                            "Profile/MIDP-2.0 Configuration/CLDC-1.1");
                    lineNumber =3;
                    out = getHc().openOutputStream();
                    lineNumber = 4;
                    PrintStream pout = new PrintStream(out);
                    lineNumber = 5;
                    pout.println(fileName);
                    lineNumber = 6;
                    pout.flush();
                    System.out.println("File Name: "+fileName);
                    lineNumber = 7;
                    is = getHc().openDataInputStream();
                    long len = getHc().getLength();
                    lineNumber = 8;
                    byte temp[] = new byte[(int)len];
                    lineNumber = 9;
                    System.out.println("len "+len);
                    is.readFully(temp,0,(int)len);
                    lineNumber = 10;
                    setFileData(temp);
                    lineNumber = 11;
                    is.close();
                    lineNumber = 12;
                    if(getFileData() != null)
                        setDownloaded(true);
                    else
                        setDownloaded(false);
                    System.out.println("Length : "+temp.length);
                    midlet.setAttachFile(getFileData());
                    lineNumber = 13;
                    pout.close();
                    lineNumber = 14;
                    out.close();
                    lineNumber = 15;
                    getHc().close();
            } catch(Exception ex){
                setDownloaded(false);
                ex.printStackTrace();
                midlet.alertScreen = new AlertScreen("Error C2+ line"+lineNumber,
                        ex.toString()+
                        " | ",
                        null, AlertType.ERROR);
                midlet.alertScreen.setTimeout(Alert.FOREVER);
                midlet.display.setCurrent(midlet.alertScreen);
        public HttpConnection getHc() {
            return hc;
        public void setHc(HttpConnection hc) {
            this.hc = hc;
        public String getUrl() {
            return url;
        public void setUrl(String url) {
            this.url = url;
        public byte[] getFileData() {
            return fileData;
        public void setFileData(byte[] fileData) {
            this.fileData = fileData;
        public boolean isDownloaded() {
            return downloaded;
        public void setDownloaded(boolean downloaded) {
            this.downloaded = downloaded;
    }here is the servlet side...
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            if(request.getMethod().equals("POST")){
                BufferedReader dataIN = request.getReader();
                String fileName = dataIN.readLine();
                File file = new File(fileName);
                String contentType = getServletContext().getMimeType(fileName);
                response.setContentType(contentType);
                System.out.println("Content Type: "+contentType);
                System.out.println("File Name: "+fileName);
                int size = (int)file.length()/1024;
                if(file.length() > Integer.MAX_VALUE){
                    System.out.println("Very Large File!!!");
                response.setContentLength(size*1024);
                FileInputStream fis = new FileInputStream(fileName);
                byte data[] = new byte[size*1024];
                fis.read(data);
                System.out.println("data lenght: "+data.length);
                ServletOutputStream sos = response.getOutputStream();
                sos.write(data);
    //            out.flush();
            }else{
                response.setContentType("text/plain");
                PrintWriter out = response.getWriter();
                BufferedReader dataIN = request.getReader();
                String msg_uid = dataIN.readLine();
                System.out.println("Msg_uid"+msg_uid);
                JDBConnection dbconn = new JDBConnection();
                String fileName = dbconn.getAttachment(msg_uid);
                String[] fileNames = fileName.split(";");
                int numFiles = fileNames.length;
                out.println(numFiles);
                for(int i = 0; i<numFiles; i++){
                    out.println(fileNames);
    out.flush();
    out.close();
    Message was edited by:
    Mark.Ramos222

    1) Have you looked up the symbian error -36 on new-lc?
    2) Have you tried the example in the response on forum nokia?
    3) Is the address "121.97.220.162:8084" accessible from the internet, on the device, on the specified port?

  • Connection refused--while executing (HttpConnection) Connector.open(url);

    Hi,
    i'm using netbeans mobility 5.0
    as i was new to this mobile programming i'm getting the output as "Connection Refused"
    plz plz plz plz....... help me out from this problem
    here is my code..
    code:_
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.io.*;
    public class FileViewer extends MIDlet implements CommandListener
    private Display display; // Reference to Display object
    private TextBox tbViewer; // View file contents in a textbox
    private Command cmView; // Command to view file
    private Command cmExit; // Command to exit
    private String url = "http://www.corej2me.com/midpbook_v1e1/scratch/fileViewer.hlp";
    public FileViewer()
    display = Display.getDisplay(this);
    // Define commands
    cmView = new Command("View", Command.SCREEN, 2);
    cmExit = new Command("Exit", Command.EXIT, 1);
    tbViewer = new TextBox("Viewer", "", 250, TextField.ANY);
    tbViewer.addCommand(cmView);
    tbViewer.addCommand(cmExit);
    tbViewer.setCommandListener(this);
    public void startApp()
    display.setCurrent(tbViewer);
    private void viewFile() throws IOException
    HttpConnection http = null;
    InputStream iStrm = null;
    try
    http = (HttpConnection) Connector.open(url);
    // Client Request
    // 1) Send request method
    http.setRequestMethod(HttpConnection.GET);
    // 2) Send header information (this header is optional)
    http.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
    // 3) Send body/data - No data for this request
    // Server Response
    // 1) Get status Line
    System.out.println("Msg: " + http.getResponseMessage());
    System.out.println("Code: " + http.getResponseCode());
    // 2) Get header information
    if (http.getResponseCode() == HttpConnection.HTTP_OK)
    // 3) Get data (show the file contents)
    iStrm = http.openInputStream();
    int length = (int) http.getLength();
    if (length > 0)
    byte serverData[] = new byte[length];
    iStrm.read(serverData);
    tbViewer.setString(new String(serverData));
    finally
    if (iStrm != null)
    iStrm.close();
    if (http != null)
    http.close();
    public void pauseApp()
    public void destroyApp(boolean unconditional)
    public void commandAction(Command c, Displayable s)
    if (c == cmView)
    try
    viewFile();
    catch (Exception e)
    System.out.println(e.toString());
    else if (c == cmExit)
    destroyApp(false);
    notifyDestroyed();
    output*
    build.xml(debug)*
    some....
    Application descriptor does not declare any MIDlet. Direct execution is not allowed.
    Generated "C:\Documents and Settings\Lakshmi Narayan J\jlnexample\dist\jlnexample.jar" is 2655 bytes.
    post-jar:
    debug:
    C:\Documents and Settings\Lakshmi Narayan J\jlnexample\src\.timestamp
    Starting emulator in debug server mode on port 1469
    com.sun.kvem.midletsuite.InvalidJadException: Reason = 22
    The manifest or the application descriptor MUST contain the attribute: MIDlet-1
    nbdebug:
    KdpDebugTask connecting to debugger 1 ..
    KdpDebugTask connecting to debugger 2 ..
    KdpDebugTask connecting to debugger 3 ..
    KdpDebugTask connecting to debugger 4 ..
    KdpDebugTask connecting to debugger 5 ..
    Connecting JPDA Debugger to emulator timed out after 5 attempts and 31 seconds.
    C:\Documents and Settings\Lakshmi Narayan J\jlnexample\nbproject\build-impl.xml:306: The following error occurred while executing this line:
    C:\Documents and Settings\Lakshmi Narayan J\jlnexample\nbproject\build-impl.xml:311: Connecting JPDA Debugger to emulator timed out after 5 attempts and 31 seconds.
    BUILD FAILED (total time: 43 seconds)
    Debugger console:
    Attaching to localhost:1469
    Connection refused.
    Edited by: LAKSHMI_NARAYAN_J on Jun 23, 2008 9:54 AM

    It's called potential deadlock. The emulator blocks your app 'cause any connection and commandAction needs its own thread. So I suggest use a new thread with this http connection then your program will be run successful.

  • How to get a HttpConnection by a WAP access point over GPRS

    Generally,every phone's WAP browser can get to every wap site by a WAP access point,and every phone can get a connection by an internet access point in J2ME too.
    But in J2ME,If APN configuration is a WAP access point,Nokia3100/6100/3650 can be successful to get a connection generally,and SonyEricsson's phone don't work.
    I'm in Philippines and use Globe Telecom's SIM card.Globe's WAP APN is "www.globe.com.ph/ewap.globe.com.ph", and internet APN is "www.globe.com.ph".
    If APN configuration is a WAP access point(www.globe.com.ph),My phone(SonyEricsson's P910C) don't work.
    following code:
    HttpConnection conn = (HttpConnection) Connector.open(url, Connector.READ_WRITE, true);
    conn.setRequestProperty("Connection", "close");
    conn.setRequestMethod(HttpConnection.GET);
    conn.setRequestProperty("User-Agent","Profile/MIDP-2.0, Configuration/CLDC-1.0");
    InputStream is = new DataInputStream(c.openInputStream());
    How to do to be able to make every phone get a connection by a WAP access point(www.globe.com.ph) in Philippines.
    For example, In China, I can set proxy property to make every phone work by a WAP access point(CMWAP).
    following code:
    //"10.0.0.172" is China Mobile's WAP gateway proxy
    HttpConnection conn = (HttpConnection) Connector.open("http://10.0.0.172:80"+URI, Connector.READ_WRITE, true);
    conn.setRequestProperty("X-Online-Host", host);
    is = conn.openInputStream();
    Reference:
    http://www.reqwireless.com/apns.html
    http://forum.java.sun.com/thread.jspa?forumID=76&threadID=509365
    http://forum.java.sun.com/thread.jspa?forumID=76&threadID=538294

    i can load my jar file in my mobile through live IP.
    it works properly when simple text,list, or any features of the MIDP
    or j2me but when i call the servlet from midlet at that time
    "java.io.exception' is fired on the mobile ...
    so please help me for that.
    why it gives us an error like this .?
    we used live ip for the communication but it gives error like this.
    i also run the application on emulator it works properly through
    the live IP but when i access from jar file in the mobile it gives
    me error.
    plz help me.
    if u have any contact no then tell me . i can call u later on.
    my mobile no is 9879236686
    my mail address is [email protected]
    u can call me also any time.

  • HttpConnection error on P900

    Hi
    I run the following code on the p900 device.
    this application connects to a url and gets a simple text message then displays it.
    ( this code is a modified example from the core j2me site examples ...)
    it doesn't work.
    on nokia 6310i device it works , also on every emulator I tried .
    I get a java.io.IOException.SymbianOSerror (something like this ...).
    the last debug message I see is :
    "Attempting to create HttpConnection object" . and then the finally related messages.
    what should I do in order to make this work on p900 ?
    package home;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.io.*;
    import javax.microedition.io.HttpConnection;
    import java.io.*;
    import java.lang.StringBuffer;
    public class HttpConn extends MIDlet implements CommandListener , Runnable
      private Display display;
      //TextBox tbMain;
      Form tbMain;
      private Command cmExit;
      private String url = "http://www.corej2me.com/midpbook_v1e1/ch14/getHeaderInfo.txt";
      StringBuffer dbgInfo = new StringBuffer();
      StringBuffer strBfr;
      public HttpConn()
        display = Display.getDisplay(this);
        cmExit = new Command("Exit" , Command.SCREEN , 1);
        tbMain = new Form("HTTP Connection");
        tbMain.addCommand(cmExit);
        tbMain.setCommandListener(this);
      public void run()
        try
          processRequest();
        catch (Exception e)
          dbgInfo.append("run : caught Exception\n");
          dbgInfo.append("run : Exception : " + e.getClass().getName());
          dbgInfo.append("run : Exception message : " + e.getMessage());
          dbgInfo.append("run : Exception string : " + e.toString());
          // also, you should probably display the exception on-screen using an alert or form
          // so that you can see it when running on the phone
          Form f = new Form("Error");
          f.append("An error occurred while connecting : ");
          f.append(new String(dbgInfo));
          f.addCommand(cmExit);
          f.setCommandListener(this);
          display.setCurrent(f);
      public void startApp()
        // set a displayable before you start the connection
        Form f = new Form("Connecting");
        f.append("    Connecting ...\n    Please wait");
        display.setCurrent(f);
        // run the connection in a separate thread
        Thread th = new Thread(this);
        // starts a new thread and calls the run() method in it.
        th.start();
      private void processRequest() throws Exception
        HttpConnection http = null;
        InputStream iStrm = null;
        try
          // Create the connection
          dbgInfo.append("Attempting to create HttpConnection object\n");
          http = (HttpConnection) Connector.open(url);
          // Client Request
          // 1) Send request method
          http.setRequestMethod(HttpConnection.GET);
          // 2) Send header information (this header is optional)
          http.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
          //http.setRequestProperty("If-Modified-Since", "Mon, 16 Jul 2001 22:54:26 GMT");
          // If you experience IO problems, try
          // removing the comment from the following line
          http.setRequestProperty("Connection", "close");
          http.setRequestProperty("Cache-Control", "no-transform");
          // 3) Send body/data - No data for this request
          // Server Response
          // 2) Get header information
          if (http.getResponseCode() == HttpConnection.HTTP_OK) {
            // 3) Get data (show the file contents)
            //String str = new String("initial value");
            dbgInfo.append("Attempting to open the input stream\n");
            iStrm = http.openInputStream();
            int length = (int) http.getLength();
            dbgInfo.append("http.getLength() : "+length+"\n");
            if (length != -1)
                // Read data in one chunk
                byte serverData[] = new byte[length];
                dbgInfo.append("Attempting to read da input stream\n");
                iStrm.read(serverData);
                char chars[] = new char[length];
                for (int i = 0 ; i < length ; i++ )
                  chars[i] = (char) serverData;
    dbgInfo.append("Attempting str = new String(serverData)\n");
    strBfr = new StringBuffer(new String(chars));
    dbgInfo.append("end if\n");
    else // Length not available...
    dbgInfo.append(
    "Attempting to read the input stream one char at a time\n");
    ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
    // Read data one character at a time
    int ch;
    while ( (ch = iStrm.read()) != -1)
    bStrm.write(ch);
    dbgInfo.append("Attempting str = new String(bStrm.toByteArray())\n");
    strBfr = new StringBuffer(new String(bStrm.toByteArray()));
    dbgInfo.append("Attempting bStrm.close()\n");
    bStrm.close();
    dbgInfo.append("Attempting tbMain.setString\n");
    tbMain.append("core j2me site file content :\n" + strBfr);
    dbgInfo.append("display.setCurrent(tbMain)\n");
    display.setCurrent(tbMain);
    dbgInfo.append("end else\n");
    finally
    dbgInfo.append("finally\n");
    if (iStrm != null)
    iStrm.close();
    if (http != null)
    http.close();
    dbgInfo.append("out of finally\n");
    public void pauseApp()
    public void destroyApp(boolean unconditional)
    public void commandAction( Command c, Displayable s )
    if ( c == cmExit )
    destroyApp(false);
    notifyDestroyed();

    Guys I finally managed to get a HTTP connection working on my P900. The problem was to do with my Mobile Network SP. It seems that they are limited in intelligence so when you say that you want access to the internet they will set you up to go to a WAP gateway which translates your requests and responses for your handset. I kept getting a -36 Symbian OS error which implied that the connection was being cut, since a the host name was resolved. After I had argued with the Data Support people for my network, explaining to them that WAP is not the a full Internet access, they finally managed to give me the right dns etc entries and my application was successfully able to communicate.
    Hope this helps, I have another problem to do with installing the same applications on the P900i but I will leave that for another forum :)

  • HttpConnection.getResponseCode() return -1

    Hi guy's
    I am developing a midp application which is communicate with server and display the result on the client using HttpConnection.Basically i am from bangalore,India and using Airtel,Vodafone connections for GPRS. My jar file is properly working in the Sony Ericsson models(k800i,k310i) with airtel and vodafone connections. But the same jar file is failed to communicate with server in Nokia models. HttpConnection.getResponseCode() return -1 in Nokia 6020,6070,6300 devices. Even N6030 is also return same value with vodafone. But same time application working fine in another 6030 model with airtel. Please look at my source code below.
    private static String requestToServer(final String url, final String data)throws IOException {
    HttpConnection httpCon = null;
    InputStream inputStream = null;
    String result = null;
    try {
    while (true) {
    httpCon = (HttpConnection) Connector.open(connectionUrl,Connector.READ_WRITE);
    httpCon.setRequestMethod(HttpConnection.POST);
    final String conf = System.getProperty("microedition.configuration");
    final String prof = System.getProperty("microedition.profiles");
    httpCon.setRequestProperty("User-Agent","Profile/" + prof + " Configuration/" + conf);
    writeDataToConnection(httpCon, data);
    if (!isRedirectResponse(httpCon)) {
    break;
    connectionUrl = httpCon.getHeaderField("Location");
    httpCon.close();
    inputStream = httpCon.openInputStream();
    result = readStreamData(inputStream);
    } catch (final ClassCastException e) {
    throw new IllegalArgumentException("Not an HTTP URL"); }
    catch (final IOException e) { throw e; }
    catch (final Exception e) { throw e; }
    finally {
    if (inputStream != null) { inputStream.close(); }
    if (httpCon != null) { httpCon.close(); }
    return result;
    private static void writeDataToConnection(final HttpConnection c, final String data) throws IOException {
    final OutputStream os = c.openOutputStream();
    try {
    final DataOutputStream dos = new DataOutputStream(os);
    dos.writeUTF(data);
    dos.flush();
    catch(IOException e) { throw e; }
    finally { os.close(); }
    private static boolean requestToServer(final HttpConnection httpCon)throws IOException {
    boolean result = false;
    final int conResponseCode = httpCon.getResponseCode();
    switch (conResponseCode) {
    case HttpConnection.HTTP_OK:
    result = false;
    break;
    case HttpConnection.HTTP_MOVED_TEMP:
    if (DEBUG_REDIRECT) {
    System.out.println("Request is redirected"); }
    result = true;
    break;
    default:
    throw new IOException("HTTP response code: " + conResponseCode);
    return result;
    In the Nokia models, the httpCon.getResponseCode() return -1. Can anybody tell me, whats the problem and what the solution for this please.
    Regards,
    Jobin

    use this ---> return new int[]{1,3};

  • Downloading files using HttpConnection is very slow

    Hi
    I've written a program which will download files over HTTP protocol using the class HttpConnection. I am connecting to the net using Proxy with authorization. At times it takes long time to download even a 2 MB file, but it works very fast on fewer occasions. The same file If I try to download using browser such as IE or FireFox, download happens in few seconds.
    I am not sure where the problem is. Can anyone guide me on this issue?
    Regards,
    Faisal

    The HTTPUrlConnection do not seem to utilize the
    Connection Keep Alive feature of HTTP so it createa
    seperate connection for each request.Eh? The Sun implementation can utilize HTTP
    Connection Keep Alive if you tell it to, and it also
    runs a connection pool.Great! can you explain a bit how you enable it?
    Can I just do it by setting the Connection: Keep-Alive header

  • HttpConnection hangs in my T630. Please Help !

    Hi all,
    I`ve noticed this problem in a few threads on this forum, but none of them seem to have a definitive answer. Maybe we can answer it once and for all here :-) Any help would be greatly appreciated.
    I`m trying to load a web page from a midlet in my T630. As I don`t really want to pay for call charges during development, I`m using the "Device Explorer" and the "Connection proxy" to try and connect to the internet using my broadband connection. I'm using the SonyEricsson developer kit (version 1) and I'm using a bluetooth serial connection on COM5 for the connection proxy.
    I've based my code on some sample code from Sun to load some info from a web page. This code was even published to get around the IO blocking problem that I seem to be getting still !
    The problem is when I try and use the HttpConnection.getResponseCode() method. Using the advice of other internet resources, I`ve put this code in its own thread. When I call HttpConnection.getResponseCode(), my T630 then pops ups with a menu, offering me these 3 options:
    Allow Web access
    Ask per access
    Deny Web access
    When this happens, it`s as if the thread running the getResponseCode() method blocks, and the T630 OS takes over. When I select an item from that menu, control does not pass back to the thread running getResponseCode(), but goes to the main midlet thread. Once I`m back in the main midlet thread, I don't know how to wake up the url loading thread. Does anyone have any ideas.
    My debugging statements produce the following before the app hangs:
    url=http://java.sun.com
    conn=com.sun.midp.io.j2me.http.Protocol@e4857a1d
    here
    Connecting to http://java.sun.comHere is the source code:
    package com.pg.midp.http;
    import java.io.IOException;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;
    import javax.microedition.lcdui.TextBox;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    // Simple class that connects to a given URL and
    // prints out the response code and any headers
    // that are sent back. Shows how to use background
    // threads to make HTTP connections while keeping the
    // user interface alive.
    public class HttpLogger extends MIDlet
         private Display display;
         private Command exitCommand = new Command([quot][/quot]Exit[quot][/quot], Command.EXIT, 1);
         private Command okCommand = new Command([quot][/quot]OK[quot][/quot], Command.OK, 1);
         private Command cancelCommand = new Command([quot][/quot]Cancel[quot][/quot], Command.CANCEL, 1);
         private URLEntry mainForm;
         // Standard MIDlet stuff....
         public HttpLogger()
         protected void debug(String s)
              System.out.println(s);
         protected void destroyApp(boolean unconditional) throws MIDletStateChangeException
              exitMIDlet();
         protected void pauseApp()
         protected void startApp() throws MIDletStateChangeException
              if (display == null)
                   initMIDlet();
         private void initMIDlet()
              display = Display.getDisplay(this);
              mainForm = new URLEntry();
              display.setCurrent(mainForm);
         public void exitMIDlet()
              notifyDestroyed();
         // Utility routine to display exceptions.
         void displayError(Throwable e, Displayable next)
              Alert a = new Alert([quot][/quot]Exception[quot][/quot]);
              a.setString(e.toString());
              a.setTimeout(Alert.FOREVER);
              display.setCurrent(a, next);
         // Simple entry form for entering the URL to
         // connect to.
         class URLEntry extends TextBox implements CommandListener
              URLEntry()
                   super([quot][/quot]Enter URL:[quot][/quot], [quot][/quot]java.sun.com[quot][/quot], 100, 0);
                   addCommand(exitCommand);
                   addCommand(okCommand);
                   setCommandListener(this);
              public void commandAction(Command c, Displayable d)
                   if (c == exitCommand)
                        exitMIDlet();
                   else if (c == okCommand)
                        try
                             String url = [quot][/quot]http://[quot][/quot] + getString();
                             debug([quot][/quot]url=[quot][/quot] + url);
                             HttpConnection conn = (HttpConnection) Connector.open(url);
                             debug([quot][/quot]conn=[quot][/quot] + conn);
                             Logger logger = new Logger(this, conn);
                             debug([quot][/quot]here[quot][/quot]);
                             display.setCurrent(logger);
                        catch (IOException e)
                             displayError(e, this);
         //      Simple form that contains a single string item.
         //      The string item is updated with status messages.
         //      When constructed, it starts a background thread
         //      that makes the actual HTTP connection. Displays
         //      a Cancel command to abort the current connection.
         class Logger extends Form implements Runnable, CommandListener
              private Displayable next;
              private HttpConnection conn;
              private StringItem text = new StringItem(null, [quot][/quot][quot][/quot]);
              boolean done = false;
              Thread t;
              Logger(Displayable next, HttpConnection conn)
                   super([quot][/quot]HTTP Log[quot][/quot]);
                   this.next = next;
                   this.conn = conn;
                   addCommand(cancelCommand);
                   setCommandListener(this);
                   append(text);
                   t = new Thread(this);
                   t.start();
              // Handle the commands. First thing to do
              // is switch the display, in case closing/
              // the connection takes a while...
              public void commandAction(Command c, Displayable d)
                   display.setCurrent(next);
                   try
                        conn.close();
                   catch (IOException e)
                        displayError(e, next);
              // Do the connection and processing on
              // a separate thread...
              public void run()
                   try
                        update([quot][/quot]Connecting to [quot][/quot] + conn.getURL());
                        try
                             int rc = conn.getResponseCode();
                             update([quot][/quot]Response code: [quot][/quot] + rc);
                             update([quot][/quot]Response message: [quot][/quot] + conn.getResponseMessage());
                             String key;
                             for (int i = 0; (key = conn.getHeaderFieldKey(i)) != null; ++i)
                                  update(key + [quot][/quot]: [quot][/quot] + conn.getHeaderField(i));
                        catch (IOException e)
                             update([quot][/quot]Caught exception: [quot][/quot] + e.toString());
                   catch (Exception e)
                        debug(e.getMessage());
                        e.printStackTrace();
                   finally
                   done = true;
                   removeCommand(cancelCommand);
                   addCommand(okCommand);
              // Update the string item with new information.
              // Only do it if we're actually visible.
              void update(String line)
                   debug(line);
                   if (display.getCurrent() != this)
                        return;
                   String old = text.getText();
                   StringBuffer buf = new StringBuffer();
                   buf.append(old);
                   if (old.length() [gt][/gt] 0)
                        buf.append('\n');
                   buf.append(line);
                   text.setText(buf.toString());
    }Thanks,
    Paul.

    Hi, Paulgrime:
    These days I also have struggled with the problem.
    I just saw a java example from SUN site, which does not use getResponseCode(). It seems a good work around.
    I tried that way and works fine. Only thing is you have to figure out the response status by analysing the inputstream content, which is actually easy.
    So I go this way now.
    Huiyi

  • HttpConnection works only in MIDlet startapp()

    I have this MIDlet that verifies if a RecordStore exists and if not it makes a connection and retrieves data from a java webservice. It's fairly simple - i've included the framework below:
    public void startApp() {
         rsPatient = openRecordStore(RECORD_STORE_PATIENT);
         if(rsPatient.getNumRecords() > 0) {
              System.out.println("rsPatient: " + rsPatient.getSize() + " bytes");
         else {
              final Hashtable parameters = new Hashtable(1);
              parameters.put("languagePrefix", activeLanguagePrefix);
              showMessageForm("Downloading patient data...");
              Thread connectionThread = new Thread() {
                   public void run() {
                        //make a SOAP connection and save envelope
                        WSConnection(aMethod, parameters);
              connectionThread.start();
              try {
                   connectionThread.join();
              catch(InterruptedException ie) {
                   ie.printStackTrace();
              //do something with envelope
              System.out.println("rsPatient created (" + rsPatient.getSize() + " bytes)");
    I'm a bit confused because if i delete the RecordStore (making the MIDlet connect to the webservice) I have no problem connecting again later during runtime. But it seems that i'm unable to make additional connections if the RecordStore already existed. That is, if the MIDlet did not need to connect to the webservice and retrieve the data, later during runtime I'm suddenly unable to connect using this line (which is the very same line as the MIDlet would use earlier if the RecordStore was empty):
    connection = (HttpConnection) Connector.open(url, Connector.READ_WRITE, true);
    This comes from a SOAP implementation (ksoap2) which I used, so the HttpConnection is a class in package org.ksoap2. I narrowed it down to this line, but no exceptions are thrown, no error messages appear, and a System.out.println of the above line shows nothing. I can se nothing extraordinary going on besides the above frameword that could make a change, so why is this necessary? Thanks in advance!

    You shouldn't be doing all of that in the startApp() method. The lifecycle methods are expected to return quickly, not to do thread-blocking activity like HTTP connections. Try spawning that off into a separate thread....

  • HttpConnection.POST to an ASP page

    First - I'm new to J2ME & I'm a novice to java in general. I'm an ASP programmer & I need to write an app for a nextel phone in J2ME.
    I have written a test application that just sends an http request to my asp page and the page should send back the appropriate response to be displayed on the phone, however the asp page does not seem to be receiving the data. However it IS sending back a response. I have tried removing flush() from the dataOutputStream, but that didn't fix the problem. Here is the code inside my MIDlet:
    private void loginViaHTTPConnection(String strLogin) throws IOException {
    HttpConnection hconn = null;
    InputStream is = null;
    OutputStream os = null;
    StringBuffer data = new StringBuffer();
    try {
    hconn = (HttpConnection)Connector.open(url);
    hconn.setRequestMethod(HttpConnection.POST);
    hconn.setRequestProperty("IF-Modified-Since",
    "20 Jan 2001 16:19:14 GMT");
    hconn.setRequestProperty("User-Agent",
    "Profile/MIDP-2.0 Configuration/CLDC-1.0");
    hconn.setRequestProperty("Content-Language", "en-CA");
    os = hconn.openOutputStream();
    // send request to the ASP script
    String str = "PIN=" + strLogin;
    byte postmsg[] = str.getBytes();
    for(int i=0;i < postmsg.length;i++) {
    os.write(postmsg);
    //os.flush();
    //receive response
    is = hconn.openDataInputStream();
    int ch;
    while((ch = is.read()) != -1) {
    data.append((char) ch);
    } finally {
    if(is!= null) {
    is.close();
    if(os != null) {
    os.close();
    if(hconn != null) {
    hconn.close();
    resultItem.setText(data.toString());
    display.setCurrent(resultScreen);
    The ASP code is:
    <%
    PIN = request("PIN")
    If PIN = "" Then
    response.write "INVALID"
    Else
    response.write "GOOD"
    End If
    %>
    The response returned is always "INVALID" no matter what I pass it.
    Any help would be greatly appreciated.

    deepspace
    Thank you, Thank you, Thank you!!!
    That worked like a charm.
    Working Code in case anyone's interested:
    private void loginViaHTTPConnection(String strLogin) throws IOException {
            HttpConnection hconn = null;
            InputStream is = null;
            OutputStream os = null;
            StringBuffer data = new StringBuffer();
            try {
                String str = "PIN=" + strLogin + '\r';
                hconn = (HttpConnection)Connector.open(url);
                hconn.setRequestProperty("IF-Modified-Since",
                        "20 Jan 2001 16:19:14 GMT");
                hconn.setRequestProperty("User-Agent",
                        "Profile/MIDP-2.0 Configuration/CLDC-1.0");
                hconn.setRequestProperty("Content-Language", "en-CA");
                hconn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");          
                hconn.setRequestMethod(HttpConnection.POST);
                // Send request to ASP page
                os = hconn.openOutputStream();
                os.write(str.getBytes());
                os.flush();
                //receive response
                is = hconn.openDataInputStream();
                int ch;
                while((ch = is.read()) != -1) {
                    data.append((char) ch);
            } finally {
                if(is!= null) {
                    is.close();
                if(os != null) {
                    os.close();
                if(hconn != null) {
                    hconn.close();
            resultItem.setText(data.toString());
            display.setCurrent(resultScreen);
        }

  • Setting a timeout for HttpConnection?

    Hi,
    Is there any way to set a timeout for an HttpConnection instance? I've got something like:
    HttpConnection conn = (HttpConnection)Connector.open("www.mysite.com");
    but the timeout on my particular device waits 2 minutes! I'd like to make it something more like 20 seconds. Any way to do this?
    Thanks

    I am surprised that HttpConnection doesn't have a way to timeout already. I searched thru the docs and I cant find any.
    Anyway this is my solution. Use a Thread. Start the thread before calling Connector.open. In the run method of the thread, sleep for 20 secs, wake up and display something to the user. This is assuming that your Connector.open is not blocking. i.e its in a thread of its own. this is an example of a non-blocking httpconnection
      public void commandAction(Command c, Displayable s) {
            if (c.getLabel().equals("GET")) {
                final MIDlet middy = this;
                new Thread() {
                    public void run() {
                        try {
                            //make your http connection here.
                            HttpConnection conn = (HttpConnection)Connector.open("www.mysite.com");
                        } catch (Exception ie) {
                            ie.printStackTrace();
                }.start();
        }of course there are other ways to do that. just my suggestion

  • JSR172 or HttpConnection error

    Hello,
    I use a J2ME application as webservice client with JSR172 Webservice API support. When I try to send a large String with more than 1680 characters to webserver I get a java.rmi.MarshalException: SAXParseException and the message has not received the server. Maybe there is some limit in length?
    To check it out I try to build the soap query manually and send it over a httpConnection with POST to webserver (without JSR172). Now I get the result "Bad Request". The string contains only normal characters.
    Any idea why this happens? I can say that the webserver has no error.
    Thanks for reply.
    Background:
    I try to send a picture as base64String manually encoded to webserver. This is the reason for the long string. The support or byte[] in stub generator seems not to work correct.

    Guys I finally managed to get a HTTP connection working on my P900. The problem was to do with my Mobile Network SP. It seems that they are limited in intelligence so when you say that you want access to the internet they will set you up to go to a WAP gateway which translates your requests and responses for your handset. I kept getting a -36 Symbian OS error which implied that the connection was being cut, since a the host name was resolved. After I had argued with the Data Support people for my network, explaining to them that WAP is not the a full Internet access, they finally managed to give me the right dns etc entries and my application was successfully able to communicate.
    Hope this helps, I have another problem to do with installing the same applications on the P900i but I will leave that for another forum :)

  • Multiple requests in a single HttpConnection

    this is the point,
    I would like to make a while that sends multiple requests, but with just one HttpConnection.
    something like this:
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import java.io.IOException;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    public class Ping extends Thread {
        String url;
        HttpConnection conn = null;
        DataInputStream hdin = null;
        DataOutputStream hdout = null;
        public Ping(String url) {
            this.url = url;
        public void openConnection() {
            try {
                conn = (HttpConnection) Connector.open(url);
                conn.setRequestMethod(HttpConnection.POST);
            }  catch(Exception e) {
                e.printStackTrace();
        public void efetuaConsulta() {
           int counter = 0;
           try {
                if(null == conn)
                    openConnection();
                while(counter <= 10) {
                    hdout = conn.openDataOutputStream();
                    hdout.writeInt(counter);
                    hdout.flush();
                    hdout.close();
                    hdin = conn.openDataInputStream();
                    counter = hdin.readInt() + 1;
                    hdin.close();
                    System.out.println("--> "+counter);
            } catch(Exception e) {
                e.printStackTrace();
        public void run() {
            efetuaConsulta();
    }well, this the idea, but its not working....
    this class would send an incremented int every request to my servlet,
    in another project, my servlet would do something....
    but this is not working because it says my DataOutputStream is already opened.
    I tried to do a singleton too, but it doesnt work....
    someone knows how to do it?
    I know it's possible because midp1.0 supports HTTP1.1
    and HTTP1.1 support what Im trying to do here....

    Http 1.1 is not supported. You could implement that yourself...
    try to move the openconnection into the while loop. that should work

Maybe you are looking for

  • Bold character style does not inherit the paragraph emphasis (Italic)

    Hi, I am using TCS2 (RH 8, FM 9). I have a character style in FrameMaker that makes GUI terms bold.  My text for Notes, Tips and so in is italic and when I apply my GUI character style in FM, the text becomes both bold and italic.  In RoboHelp, my te

  • How to put integer in a file

    Who knows how to record data in the file that after recording, it will not be'abrakadabra', but very distinctive files for example with integer. Thank you in advance

  • I'm having trouble finding firefox sync on my desktop and to download to my ipad2 for schoolwork!

    I'm having trouble finding firefox sync on my desktop AND getting it over to my ipad2. I've been through all the support and still can't find it. Please help! I need it for my schoolwork!

  • How to store multiple child nodes using dbms_xmlstore

    Hi, I'm using oracle 10g environment. In DBMS_XMLSTORE package I cannot able to insert the multiple child node value into db table. Here I have given the xml value <DATAPACKET REQUEST-ID="10001094">   <HEADER>     <SEARCH-RESULT-LIST>       <SEARCH-R

  • XP Table Header on 1.4.2_06

    Hi there I have a JTable with five columns. On the first two columns, I have made custom renderers to show a picture in the table header. The rest of the columns are normal. There is a screenshot of what I mean at the site below. http://www.geocities