hi everybody
i write a bluetooth spp server
and this is the code i have been written


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

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import java.util.Hashtable;
import java.util.Vector;

// jsr082 API
import javax.bluetooth.DataElement;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.ServiceRecord;
import javax.bluetooth.ServiceRegistrationException;
import javax.bluetooth.UUID;

// midp/cldc API
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.StreamConnectionNotifier;

/**
* @author Tariq
*/
public class VisualMIDlet extends MIDlet implements CommandListener {
StreamConnectionNotifier service;
ServiceRecord sr;
StreamConnection connection;
String ServiceURL =
"btspp://localhost:10203040607040A1B1C1DE100;name=SPPServer 1";
StreamConnectionNotifier notifier;
String str;
InputStream is ;
OutputStream os ;
private boolean midletPaused = false;

//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">
private Alert alert;
private Form form;
private Command okCommand;
private Command recive;
private Command exit;
//</editor-fold>

/**
* The VisualMIDlet constructor.
*/
public VisualMIDlet() {
}

//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">
/**
* Initilizes the application.
* It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
*/
private void initialize() {
// write pre-initialize user code here

// write post-initialize user code here
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet() {
// write pre-action user code here
switchDisplayable(null, getAlert());
// write post-action user code here
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">
/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet() {
// write pre-action user code here

// write post-action user code here
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">
/**
* Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
* @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
* @param nextDisplayable the Displayable to be set
*/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
// write pre-switch user code here
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}
// write post-switch user code here
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">
/**
* Called by a system to indicated that a command has been invoked on a particular displayable.
* @param command the Command that was invoked
* @param displayable the Displayable where the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {
// write pre-action user code here
if (displayable == alert) {
if (command == okCommand) {
// write pre-action user code here
switchDisplayable(null, getForm());
// write post-action user code here
}
} else if (displayable == form) {
if (command == exit) {
// write pre-action user code here
exitMIDlet();
// write post-action user code here
} else if (command == recive) {
// write pre-action user code here
try {
// create a server connection
notifier =(StreamConnectionNotifier) Connector.open(ServiceURL);
// accept client connections
connection = notifier.acceptAndOpen();
// prepare to send/receive data
byte buffer[] = new byte[100];
String msg = "hello there, client";
is = connection.openInputStream();
os = connection.openOutputStream();
// send data to the client
os.write(msg.getBytes());
// read data from client
is.read(buffer);
StringBuffer buffer1 = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = is.read(b)) != -1;) {
buffer1.append(new String(b, 0, n));
}
str = buffer.toString();
System.out.println(str);
os.close();
is.close();
connection.close();
} catch(IOException e) {
e.printStackTrace();
}

// write post-action user code here
}
}
// write post-action user code here
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert ">
/**
* Returns an initiliazed instance of alert component.
* @return the initialized component instance
*/
public Alert getAlert() {
if (alert == null) {
// write pre-init user code here
alert = new Alert("alert", "final year project", null, null);
alert.addCommand(getOkCommand());
alert.setCommandListener(this);
alert.setTimeout(Alert.FOREVER);
// write post-init user code here
}
return alert;
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">
/**
* Returns an initiliazed instance of form component.
* @return the initialized component instance
*/
public Form getForm() {
if (form == null) {
// write pre-init user code here
form = new Form("form");
form.addCommand(getRecive());
form.addCommand(getExit());
form.setCommandListener(this);
// write post-init user code here
}
return form;
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">
/**
* Returns an initiliazed instance of okCommand component.
* @return the initialized component instance
*/
public Command getOkCommand() {
if (okCommand == null) {
// write pre-init user code here
okCommand = new Command("Ok", Command.OK, 0);
// write post-init user code here
}
return okCommand;
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: recive ">
/**
* Returns an initiliazed instance of recive component.
* @return the initialized component instance
*/
public Command getRecive() {
if (recive == null) {
// write pre-init user code here
recive = new Command("Ok", Command.OK, 0);
// write post-init user code here
}
return recive;
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exit ">
/**
* Returns an initiliazed instance of exit component.
* @return the initialized component instance
*/
public Command getExit() {
if (exit == null) {
// write pre-init user code here
exit = new Command("Back", Command.BACK, 0);
// write post-init user code here
}
return exit;
}
//</editor-fold>

/**
* Returns a display instance.
* @return the display instance.
*/
public Display getDisplay () {
return Display.getDisplay(this);
}

/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable (null, null);
destroyApp(true);
notifyDestroyed();
}

/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet ();
} else {
initialize ();
startMIDlet ();
}
midletPaused = false;
}

/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
}

/**
* Called to signal the MIDlet to terminate.
* @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
}

}







the emulator work until
the message
" MobileApllication1 wants to open bluetooth server .this mean another device can connect to yours IS it ok"
and when i press yes or no
no thing happend
but i need to accept yes and show the value of recived input steam on the screen


please if any have use a use full information help me
and thanks alot