Olá, estou tentando passar uma string por http pelo celular, já verifiquei e parece q está dando certo, recebi o código de resposta http=200, ou seja tudo ocorreu legal. Mas a string passada naum esta sendo impressa na pagina html…Ja testei tanto no php quanto jsp e naum deu…
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class MidletDuke extends MIDlet implements CommandListener {
private Display display;
private Form tela;
private TextField tf;
private Command cmdEnviar;
private Command cmdReceber;
protected void startApp() {
display=Display.getDisplay(this);
montarTelaInicial();
display.setCurrent(tela);
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
display.setCurrent(null);
this.notifyDestroyed();
}
private void montarTelaInicial(){
tela=new Form(" HTTP Sender");
cmdEnviar=new Command("Enviar",Command.ITEM,0);
tela.addCommand(cmdEnviar);
tela.setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
if (c==cmdEnviar){
Download a=new Download(this);
a.start();
}
}
}
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
public class Download implements Runnable {
private MidletDuke Mid;
public Download(MidletDuke mid){
this.Mid=mid;
}
public void run() {
try{
passarInformacao();
}
catch(Exception e){
}
}
public void start(){
Thread thread=new Thread(this);
try{
thread.start();
}
catch(Exception e){
}
}
private void passarInformacao(){
try{
HttpConnection con=(HttpConnection)Connector.open("http://127.0.0.1/index.php?msg=teste");
int status=0;
status=con.getResponseCode();
System.out.println(status);
}
catch(IOException e){
}
}
}
index.php
<!doctype html public “-//W3C//DTD HTML 4.0 //EN”>
<html>
<head>
<title>Title here!</title>
</head>
<body>
<?php @$teste=$HTTP_GET_VARS[‘msg’];
echo $teste;
?>
</body>
</html>
index.jsp
<html>
<head>
<title>Title here!</title>
</head>
<body>
<%String teste=request.getParameter(“msg”);
out.print(teste);%>
</body>
</html>