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. sent from J2ME to webServer

sent from J2ME to webServer

Scheduled Pinned Locked Moved Java
javawpfsysadmintoolstutorial
4 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 everybody (SORRY FOR MY BAD ENGLISH) i want to send something from mobile application wrote in J2ME to web server wrote in JSP with JAVA Servlet my question is how to get the string sent from J2ME to Web Server the code for J2ME is

    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:8080/DeleteWebApplication/RomaServlet";
    //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("ROMA4EVER");
        requestField=new TextField("enter a string please", "", 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 response back from the web server
            resultScreen=new Form("Azzuri");
            resultField=new StringItem(null,resultString);
            resultScreen.append(resultField);
            resultScreen.ad
    
    C 1 Reply Last reply
    0
    • W williamroma

      hi everybody (SORRY FOR MY BAD ENGLISH) i want to send something from mobile application wrote in J2ME to web server wrote in JSP with JAVA Servlet my question is how to get the string sent from J2ME to Web Server the code for J2ME is

      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:8080/DeleteWebApplication/RomaServlet";
      //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("ROMA4EVER");
          requestField=new TextField("enter a string please", "", 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 response back from the web server
              resultScreen=new Form("Azzuri");
              resultField=new StringItem(null,resultString);
              resultScreen.append(resultField);
              resultScreen.ad
      
      C Offline
      C Offline
      CodingLover
      wrote on last edited by
      #2

      You have to call a method (public, web method) in your web server from the app with passing the arguments.

      I appreciate your help all the time... CodingLover :)

      W 1 Reply Last reply
      0
      • C CodingLover

        You have to call a method (public, web method) in your web server from the app with passing the arguments.

        I appreciate your help all the time... CodingLover :)

        W Offline
        W Offline
        williamroma
        wrote on last edited by
        #3

        would you give me an example thank you

        C 1 Reply Last reply
        0
        • W williamroma

          would you give me an example thank you

          C Offline
          C Offline
          CodingLover
          wrote on last edited by
          #4

          Haven't you search on the web? http://www.oracle.com/technetwork/articles/javaee/j2ee-ws-140408.html

          I appreciate your help all the time... CodingLover :)

          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