how to recieve POST to localhost from J2ME
-
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
-
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