Erro ao usar HttpConnection

Pessoal estou fazendo tudo "certo" mas não estou conseguindo connectar no emulador eu estou tendo conectar em um Servlet Java, mas consigo…
abaixo segue o código por favor me ajudem !!!


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;

public class Conecao extends MIDlet implements CommandListener
{
  private Display display;	    // Reference to display object 
  private Form fmMain;         // The main form
  private TextField tfAcct;    // Get account number
  private TextField tfPwd;     // Get password
  private Command cmCall;      // Command to call the servlet
  private Command cmExit;      // Command to exit

  public Conecao()
  {
    display = Display.getDisplay(this);

    // Textfields
    tfAcct = new TextField("Conta:", "", 5, TextField.NUMERIC);
    tfPwd = new TextField("Password:", "", 10, TextField.ANY | TextField.PASSWORD);        

    // Define commands
    cmCall = new Command("Call", Command.SCREEN, 2);
    cmExit = new Command("Exit", Command.EXIT, 1);

    // Create the form, add components and commands
    fmMain = new Form("Data from servlet");
    fmMain.append(tfAcct);
    fmMain.append(tfPwd);
    fmMain.addCommand(cmExit);
    fmMain.addCommand(cmCall);    

    // Capture events
    fmMain.setCommandListener(this);    
  }

  // Called by application manager to start the MIDlet.
  public void startApp()
  {
    display.setCurrent(fmMain);
  }

  public void pauseApp()
  { }
  
  public void destroyApp(boolean unconditional)
  { }

  private void callServlet() throws IOException
  {
    HttpConnection http = null;
    InputStream iStrm = null;        

    // Data is passed at the end of url for GET
    String url = "http://localhost:8080/Locadora/GetNPostServltet" + "?" +
                 "conta=" + 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 body/data -  data is at the end of URL

      //----------------
      // Server Response
      //----------------
      if (http.getResponseCode() == HttpConnection.HTTP_OK)
      {
        iStrm = http.openInputStream();      
        // 2) Get header information - none
      
        // 3) Get body (data)
        int length = (int) http.getLength();
        if (length > 0)
        {
          byte servletData[] = new byte[length];
          iStrm.read(servletData);
  
          // Update the string item on the display
          fmMain.append("You passed to the servlet: \n" + new String(servletData));
        }
        else
          fmMain.append("Unable to read data");
      }
    }
    catch (Exception e)
    {
      fmMain.append("Network error");
      System.out.println(e.toString());
    }
    finally
    {
      // Clean up
      if (iStrm != null)
        iStrm.close();
      if (http != null)
        http.close();
    }
  }

  public void commandAction(Command c, Displayable s)
  {
    if (c == cmCall)
    {
      try
      {
        callServlet();
      }
      catch (Exception e)
      { 
        System.out.println(e.toString());
      }
    }
    else if (c == cmExit)
    {
      destroyApp(false);
      notifyDestroyed();
    }	   
  }
}

e o código do servlet…


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author Rafael
 */
public class GetNPostServltet extends HttpServlet {
   
    /** 
    * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            /* TODO output your page here
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet GetNPostServltet</title>");  
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet GetNPostServltet at " + request.getContextPath () + "</h1>");
            out.println("</body>");
            out.println("</html>");
            */
        } finally { 
            out.close();
        }
    } 

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        String conta = request.getParameter("conta");
        String pwd = request.getParameter("password");
        String balance = conta+pwd;
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        out.println(balance);
        out.close();
    } 

    /** 
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        
        String conta = request.getParameter("conta");
        String pwd = request.getParameter("password");
        String balance = conta+pwd;
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        out.println(balance);
        out.close();
        
    }

    /** 
    * Returns a short description of the servlet.
    */
    public String getServletInfo() {
        return "Short description";
    }
    // </editor-fold>
}


Pessoal eu sou novo nessa area por favor me ajudem… se alguem puder me mandar algo do tipo eu agradeceria por favor me ajudem !!!

pessoal por favor me ajudem… eu preciso fazer uma aplicação… que tenha um servido que vai pegar dados de um banco de dados e atraves do servidos eu vou usar j2me para obter os dados do servidor. por favor pessoal me de um luz “”""!!!

acho que falta implementar thread!

vc fala que não está conseguindo, mas também não fala qual erro (console) ta dando =)

mais pelo que percebi é thread…

da uma olhada aqui. Fiz uma exemplo de aplicação que valida um usuário e senha. Veja como eu fiz a thread e adapta no seu,

abraço.

http://guj.com.br/posts/list/60158.java

Até!

o pior cara que não mostra erro somente a aplicação TRAVA !!! :frowning: vai saber !!!

Primeiro pare de chorar na thread, se o pessoal puder responder vai responder, não é implorando. Posta o erro por favor, diga qual celular, como está configurado seu JAD, enfim, pra qual versão CLDC e MIDP está compilada a aplicação.