Phone recieving and sending messages

Hi there
i have configured my apache server servlet to send the message "hello world" to a phne, the phone recieves the message but when i want my phone to send a message back i get nothing just a "null" value, here is the code please take a look and let me know what is wrong:
phone side:
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class test extends MIDlet implements CommandListener{
Command connect;
String url;
Form form;
public test(){
HttpConnection hc = null;
InputStream in = null;
OutputStream out = null;
url = "http://localhost:80/testing_2/hits";
connect = new Command("Connect",Command.SCREEN,0);
form = new Form("connect");
form.addCommand(connect);
form.setCommandListener(this);
public void startApp(){
Display.getDisplay(this).setCurrent(form);
public void pauseApp(){}
public void destroyApp(boolean a){}
public void commandAction(Command c,Displayable d){
if(c==connect){
     Thread t = new Thread(){
     public void run(){
     connects();     }
     t.start();
public void connects(){
try{
     HttpConnection hc;
     InputStream in;
     OutputStream out;
     String req = "checlsea";
     hc = (HttpConnection)Connector.open(url);
     in = hc.openInputStream();
     out = hc.openOutputStream();
     try{
     int contentlength = (int)hc.getLength();
     byte[] raw = new byte[contentlength];
     int length = in.read(raw);
     in.close();
     hc.close();
     String s = new String(raw,0,length);
     System.out.println(s);
     byte post[] = req.getBytes();
     for(int i=0;i<post.length;i++){     
     out.write(post);
     System.out.println(post[i]);          
     catch(java.lang.IllegalStateException e){}
} catch(IOException e){ System.out.println("error lala");}
servlet side:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class testing2 extends HttpServlet{
private int mcount;
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
String message = "hello world";
PrintWriter out = response.getWriter();
out.println(message);
BufferedReader in = request.getReader();
int i;
byte j;
i = in.read();
System.out.print( i);
some one plz help ive been trying to solve this for aaaaaaaaaaagees, any help would be greatly appreciated, regards

hi!
you need to use the loop
for(int i=0;i<post.length;i++){
out.write(post);
System.out.println(post);
out.write(byte array);
pls use the loop to read the stream on the server side!
[email protected]

Similar Messages

Maybe you are looking for

  • I am having problems connecting my macbook air to an external display

    I recently purchased a 2012 MacBook Air, and am currently running Mountain Lion. When I try to connect an external VGA overhead projector, for use in a conference room, using the Thunderbolt to VGA adapter, my screen resolution changes, but nothing i

  • JSF h:commandButton which renders as an html button rather then input

    I've been struggling to find a way to create a jsf command button that will render as a <button>. The reason I want to do this is so that I can include content inside my button, as the html <button> tag allows. Is there a way to do this, or is this i

  • How to migratre Lightroom DB to another PC

    Hi, I recently got a more powerful PC and would like to move my Lightroom DB and photos to that PC so I can work more efficiently. I've copied the photo files to the new hard drive (same path). I then copied the Lightroom DB over top of the default o

  • Auto Populate Prompt value

    i would like to read a QUERY build from Query Manager via Peoplecode &sQryName = ""; &aRunQry = %Session.GetQuery(); &sQryName = "MY_QUERY"; If (&aRunQry.Open(&sQryName, False, False) <> 0) Then MessageBox(0, "", 0, 0, "failed to open query"); Else &

  • HELP PLEASE! Green marks near words on web browsers can't get rid of any ideas

    I have as soon as i click on a link on the web pages - green marks appear near words and they open up a new tab which shows advertised pages - how do i get rid of them. I have run spy ware but does not remove or change anything ,,, Thanks