below is my code:

i tried in emulator, return null pointer exception... can someone tell me why?
//***********************************
package example.sum;

import java.io.*;
import java.util.*;
import javax.microedition.io.*;


public class HttpPoster implements Runnable {
private String url;
private volatile boolean aborting = false;
private Vector requestQueue = new Vector();
private Vector listenerQueue = new Vector();

public HttpPoster(String url) {
this.url = url;
Thread thread = new Thread(this);
thread.start();
}

public synchronized void sendRequest(String request, HttpPosterListener listener)
throws IOException
{
requestQueue.addElement(request);
listenerQueue.addElement(listener);
notify();
}

public void run() {
running:
while (!aborting) {
String request;
HttpPosterListener listener;

synchronized (this) {
while (requestQueue.size() == 0) {
try{
wait();
}
catch(InterruptedException e) {
}

if (aborting)
break running;
}

request = (String) (requestQueue.elementAt(0));
listener = (HttpPosterListener) (listenerQueue.elementAt(0));
requestQueue.removeElementAt(0);
listenerQueue.removeElementAt(0);
}
doSend(request, listener);
}
}

private void doSend(String request, HttpPosterListener listener) {
HttpConnection conn = null;
InputStream in = null;
OutputStream out = null;
String responseStr = null;
String errorStr = null;
boolean wasError = false;

try{
conn = (HttpConnection)Connector.open(url);
conn.setRequestMethod(HttpConnection.POST);
conn.setRequestProperty("Content-Length", Integer.toString(request.length()));

out = conn.openOutputStream();
int requestLength = request.length();
for (int i = 0; i < requestLength; i++) {
out.write(request.charAt(i));
}

in = conn.openInputStream();

StringBuffer responseBuf;
long length = conn.getLength();
if (length > 0) {
responseBuf = new StringBuffer((int)length);
}
else {
responseBuf = new StringBuffer();
}

int ch;
while ((ch = in.read()) != -1){
responseBuf.append((char)ch);
}
responseStr = responseBuf.toString();

String rewrittenUrl = conn.getHeaderField("X-RewrittenURL");
if (rewrittenUrl != null) {
url = rewrittenUrl;
}
}
catch (IOException e) {
wasError = true;
errorStr = e.getMessage();
}
finally {
if (in != null) {
try {
in.close();
}
catch (IOException e) {
}
}
if (conn != null) {
try {
conn.close();
}
catch (IOException e) {
}
}
}

if (wasError) {
listener.handleHttpError(errorStr);
}
else {
listener.receiveHttpResponse(responseStr);
}
}

public void abort() {
aborting = true;
synchronized (this) {
notify();
}
}
}

//******************************
package example.sum;

import javax.microedition.lcdui.*;

public interface HttpPosterListener {
void receiveHttpResponse(String response);

void handleHttpError(String errorStr);
}

//****************************************
package example.sum;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.IOException;

public class SumMIDlet extends MIDlet {
private final SumScreen screen;
private final HttpPoster httpPoster;

/** Constructor */
public SumMIDlet() {
String servletUrl = getAppProperty("Servlet-URL");
httpPoster = new HttpPoster(servletUrl);

screen = new SumScreen(this, httpPoster);
}

/** Main method */
public void startApp() {
Display.getDisplay(this).setCurrent(screen);
}

/** Handle pausing the MIDlet */
public void pauseApp() {
}

/** Handle destroying the MIDlet */
public void destroyApp(boolean unconditional) {
}

/** Quit the MIDlet */
void sumScreenQuit() {
httpPoster.abort();
destroyApp(false);
notifyDestroyed();
}

}
//*****************************************
package example.sum;

import javax.microedition.lcdui.*;
import java.io.IOException;

class SumScreen extends Form implements CommandListener, HttpPosterListener {
private final SumMIDlet midlet;
private final HttpPoster httpPoster;
private final TextField inputField;
private final StringItem outputField;
private final Command sendCommand;
private final Command quitCommand;
private volatile boolean readyForInput = true;

SumScreen(SumMIDlet midlet, HttpPoster httpPoster) {
super("Sum");
this.midlet = midlet;
this.httpPoster = httpPoster;

inputField = new TextField("Input:", "1", 8, TextField.NUMERIC);
append(inputField);
outputField = new StringItem("Output:", "0");
append(outputField);
sendCommand = new Command("Send", Command.SCREEN, 2);
addCommand(sendCommand);
quitCommand = new Command("Quit", Command.EXIT, 2);
addCommand(quitCommand);

setCommandListener(this);
}

/**Handle command events*/
public void commandAction(Command c, Displayable d) {

if (!readyForInput){
return;
}

if (c == sendCommand) {
try {
String requestStr = inputField.getString();
httpPoster.sendRequest(requestStr, this);
readyForInput = false;
}
catch (IOException e) {
outputField.setText("Error");
}
}
else if ( c ==quitCommand){
midlet.sumScreenQuit();
}
}

public void receiveHttpResponse (String response) {
outputField.setText(response);
readyForInput = true;
}

public void handleHttpError(String errorStr) {
outputField.setText("Error");
readyForInput = true;
}
}
//***********************************
//*Sum.jar
//****************************
MIDlet-Name: MyMIDlet
MIDlet-Version: 0.0.1
MIDlet-Vendor: MyCompany
MIDlet-Jar-URL: Sum.jar
MIDlet-Jar-Size: 6124
Servlet-URL: http://localhost:8080/sum
MIDlet-1: SumMIDlet, , example.sum.SumMIDlet