Thanks a ton alexander for the quick reply.
I understood what you said perfectly.
Now I have few questions.
1)In this code tbox = new TextBox("Hello world MIDlet", "Hello World!", 25, 0); can i replace "Hello World " with some string object.
2)Could you please verify whether the code is right for sending data to the servlet.
3)Can you guide me as how to retrieve data from the servlet.
Following is my code
public void connect()
{
try
{
HttpConnection httpconnection = (HttpConnection)Connector.open(url);
System.out.println("url is" + url);
httpconnection.setRequestMethod(httpconnection.POST);
httpconnection.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
httpconnection.setRequestProperty("Content-Language", "en-US");
//byte abyte0[] = connData.getBytes();
// httpconnection.setRequestProperty("Content-Length", ))
OutputStream outputstream = httpconnection.openOutputStream();
byte abyte0[] = connData.getBytes();
for(int i=0;i<abyte0.length;i++)
{
outputstream.write(abyte0[i]);
}
outputstream.flush();
outputstream.close();
System.out.println("Connected Successfully");
int i = httpconnection.getResponseCode();
System.out.println("RC" + i);
if(i != 200)
throw new IOException("HTTP response code: " + i);
DataInputStream inputstream = httpconnection.openDataInputStream();
int j = (int)httpconnection.getLength();
System.out.println("Length of inputstream is :"+j);
byte abyte1[] = new byte[j];
int k = inputstream.read(abyte1);
System.out.println("Length inputstream.read is :"+k);
String abc=httpconnection.getResponseMessage();
String s = new String(abyte1,0,k);
System.out.println("string is:" + s + "******************************"+abc);
}