I want to create simple HttpConnection that check user authentificate on local server and display xml server response on Dialog Box in Black berry
package com.bbtest;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.io.StreamConnection;

import net.rim.device.api.io.Base64OutputStream;
import net.rim.device.api.io.http.HttpProtocolConstants;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

public class LocalHttpConTest extends MainScreen{
    private BasicEditField userName;
    private BasicEditField passWord;
    private ButtonField  submit;
    byte [] strData = null;
    InputStream in;
    OutputStream os;
 public LocalHttpConTest() {
  super(DEFAULT_CLOSE|DEFAULT_MENU);
  userName=new BasicEditField("UserName","astephen@walshintegrated.coma",40,BasicEditField.FILTER_EMAIL);
  //add(userName);
  passWord=new BasicEditField("Password","awalsh@123a",20,BasicEditField.FIELD_LEFT);
  //add(passWord);
  submit=new ButtonField("Submit",ButtonField.CONSUME_CLICK);
  submit.setChangeListener(new FieldChangeListener() {
   
   public void fieldChanged(Field field, int context) {
                 getResult();

    
   }

   
  });
  
  add(submit);

}
 public void getResult() {
  
   ////String user=userName.getText().trim();
   //String pas=passWord.getText().trim();
   
   InputStream is;
   StreamConnection s;
   HttpConnection connection = null;
   
   try {
       net.rim.blackberry.api.browser.URLEncodedPostData encoder = new net.rim.blackberry.api.browser.URLEncodedPostData(null, false);
       encoder.append("userName","astephen@walshintegrated.coma");
       encoder.append("passWord","awalsh@123a");
       /* add additional data to be POSTed */

       connection = (javax.microedition.io.HttpConnection)javax.microedition.io.Connector.open("http://10.10.1.218/walshintegrated/index.php/xml/xml_rti_bb/login?");
       connection.setRequestMethod(javax.microedition.io.HttpConnection.POST);
       connection.setRequestProperty(net.rim.device.api.io.http.HttpProtocolConstants.HEADER_CONTENT_TYPE, net.rim.device.api.io.http.HttpProtocolConstants.CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
       connection.setRequestProperty(net.rim.device.api.io.http.HttpProtocolConstants.HEADER_CONTENT_LENGTH, String.valueOf(encoder.getBytes().length));

       java.io.OutputStream os = connection.openOutputStream();
       os.write(encoder.getBytes());

       if (connection.getResponseCode() == javax.microedition.io.HttpConnection.HTTP_OK) {
        is=connection.openInputStream();
     StringBuffer sb = new StringBuffer();
              String xml = "";
              int ch;
              
              while((ch=is.read()) != -1){
                  sb.append((char)ch);
              }
              
              xml = sb.toString();

     Dialog.alert(xml);
       }
   } catch (java.io.IOException e) {
   } finally {
       if (connection != null) {
           try { connection.close(); } catch (IOException e) {}
       }
   }

  
  
 }
}

I want to create simple HttpConnection that check user authentificate on local server and display xml server response on Dialog Box in Black berry
===

package com.bbtest;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.io.StreamConnection;

import net.rim.device.api.io.Base64OutputStream;
import net.rim.device.api.io.http.HttpProtocolConstants;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

public class LocalHttpConTest extends MainScreen{
    private BasicEditField userName;
    private BasicEditField passWord;
    private ButtonField  submit;
    byte [] strData = null;
    InputStream in;
    OutputStream os;
 public LocalHttpConTest() {
  super(DEFAULT_CLOSE|DEFAULT_MENU);
  userName=new BasicEditField("UserName","astephen@walshintegrated.coma",40,BasicEditField.FILTER_EMAIL);
  //add(userName);
  passWord=new BasicEditField("Password","awalsh@123a",20,BasicEditField.FIELD_LEFT);
  //add(passWord);
  submit=new ButtonField("Submit",ButtonField.CONSUME_CLICK);
  submit.setChangeListener(new FieldChangeListener() {
   
   public void fieldChanged(Field field, int context) {
                 getResult();

    
   }

   
  });
  
  add(submit);

}
 public void getResult() {
  
   ////String user=userName.getText().trim();
   //String pas=passWord.getText().trim();
   
   InputStream is;
   StreamConnection s;
   HttpConnection connection = null;
   
   try {
       net.rim.blackberry.api.browser.URLEncodedPostData encoder = new net.rim.blackberry.api.browser.URLEncodedPostData(null, false);
       encoder.append("userName","astephen@walshintegrated.coma");
       encoder.append("passWord","awalsh@123a");
       /* add additional data to be POSTed */

       connection = (javax.microedition.io.HttpConnection)javax.microedition.io.Connector.open("http://10.10.1.218/walshintegrated/index.php/xml/xml_rti_bb/login?");
       connection.setRequestMethod(javax.microedition.io.HttpConnection.POST);
       connection.setRequestProperty(net.rim.device.api.io.http.HttpProtocolConstants.HEADER_CONTENT_TYPE, net.rim.device.api.io.http.HttpProtocolConstants.CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
       connection.setRequestProperty(net.rim.device.api.io.http.HttpProtocolConstants.HEADER_CONTENT_LENGTH, String.valueOf(encoder.getBytes().length));

       java.io.OutputStream os = connection.openOutputStream();
       os.write(encoder.getBytes());

       if (connection.getResponseCode() == javax.microedition.io.HttpConnection.HTTP_OK) {
        is=connection.openInputStream();
     StringBuffer sb = new StringBuffer();
              String xml = "";
              int ch;
              
              while((ch=is.read()) != -1){
                  sb.append((char)ch);
              }
              
              xml = sb.toString();

     Dialog.alert(xml);
       }
   } catch (java.io.IOException e) {
   } finally {
       if (connection != null) {
           try { connection.close(); } catch (IOException e) {}
       }
   }

  
  
 }
}
