Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. how to recieve POST to localhost from J2ME

how to recieve POST to localhost from J2ME

Scheduled Pinned Locked Moved Java
javaphpwpfsysadmintools
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    williamroma
    wrote on last edited by
    #1

    hi for all (SORRY FOR MY BAD ENGLISH) i am really thank you all because you always help me today i am working in sending something from mobile using J2ME to localhost i put the defalutUrl="http://localhost" is this right? and how to the bytes (that i sent) to localhost , i read that the class "HttpServlet" and its functions is important to me is this right? the most important thing is how to receive to localhost and should i make a php page to receive the bytes i sent? this is the code

    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import java.io.IOException;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;
    import javax.microedition.lcdui.TextField;

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

    /**
    *
    * @author William
    */
    public class midle extends MIDlet implements CommandListener {

    private static String defalutUrl="http://localhost";
    //GUI to input string form the user
    private Display myDisplay=null;
    private Form mainScreen;
    private TextField requestField;
    
    //GUI for displaying header information
    private Form resultScreen;
    private StringItem resultField;
    
    //the "SEND" button used in the mainScreen
    Command sendCommand = new Command("SEND", Command.OK, 1);
    
    //the "BACK" button used in the resultScreen
    Command backCommand = new Command("BACK", Command.OK, 1);
    
    public midle() {
        myDisplay=Display.getDisplay(this);
        mainScreen=new Form("Type in a string:");
        requestField=new TextField(null, "TOTTI ", 100, TextField.ANY);
        mainScreen.append(requestField);
        mainScreen.addCommand(sendCommand);
        mainScreen.setCommandListener(this);
    }
    
    public void commandAction(Command c, Displayable d) {
        if(c==sendCommand){
            //retrieving the String that user had entered
            String requestString= requestField.getString();
            //sending a POST request to the web server
            String resultString= sendPostRequest(requestString);
            //displaying the
    
    L 1 Reply Last reply
    0
    • W williamroma

      hi for all (SORRY FOR MY BAD ENGLISH) i am really thank you all because you always help me today i am working in sending something from mobile using J2ME to localhost i put the defalutUrl="http://localhost" is this right? and how to the bytes (that i sent) to localhost , i read that the class "HttpServlet" and its functions is important to me is this right? the most important thing is how to receive to localhost and should i make a php page to receive the bytes i sent? this is the code

      import java.io.DataInputStream;
      import java.io.DataOutputStream;
      import java.io.IOException;
      import javax.microedition.io.Connector;
      import javax.microedition.io.HttpConnection;
      import javax.microedition.lcdui.Command;
      import javax.microedition.lcdui.CommandListener;
      import javax.microedition.lcdui.Displayable;
      import javax.microedition.midlet.MIDlet;
      import javax.microedition.midlet.MIDletStateChangeException;
      import javax.microedition.lcdui.Display;
      import javax.microedition.lcdui.Form;
      import javax.microedition.lcdui.StringItem;
      import javax.microedition.lcdui.TextField;

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

      /**
      *
      * @author William
      */
      public class midle extends MIDlet implements CommandListener {

      private static String defalutUrl="http://localhost";
      //GUI to input string form the user
      private Display myDisplay=null;
      private Form mainScreen;
      private TextField requestField;
      
      //GUI for displaying header information
      private Form resultScreen;
      private StringItem resultField;
      
      //the "SEND" button used in the mainScreen
      Command sendCommand = new Command("SEND", Command.OK, 1);
      
      //the "BACK" button used in the resultScreen
      Command backCommand = new Command("BACK", Command.OK, 1);
      
      public midle() {
          myDisplay=Display.getDisplay(this);
          mainScreen=new Form("Type in a string:");
          requestField=new TextField(null, "TOTTI ", 100, TextField.ANY);
          mainScreen.append(requestField);
          mainScreen.addCommand(sendCommand);
          mainScreen.setCommandListener(this);
      }
      
      public void commandAction(Command c, Displayable d) {
          if(c==sendCommand){
              //retrieving the String that user had entered
              String requestString= requestField.getString();
              //sending a POST request to the web server
              String resultString= sendPostRequest(requestString);
              //displaying the
      
      L Offline
      L Offline
      lakshr
      wrote on last edited by
      #2

      it is not working. i am getting below error. Kindly provide code in zip for both sending and receiving SMS in java Midlet. Thanks in advance

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups