How to write a program that allows an HTTPs connection to the APACHE TOMCAT server in blackberry JDE

Hello.. I am very new to the blackberry JDE environment. But then, I have a project in which I should write a program that will make an HTTPs connection to the apache tomcat server using blackberry JDE. The simulator which I use is 8330-JDE.

Here is my code...

import java.io.IOException;

Import java.io.InputStream;

Import javax.microedition.io.Connector;

Import javax.microedition.io.HttpsConnection;

Import net.rim.device.api.ui.UiApplication;

Import net.rim.device.api.ui.container.MainScreen;

public class Httproto extends UiApplication

{

public public static void main (String [] args)

{

Httproto instance = new Httproto();

instance.enterEventDispatcher ();

}

public Httproto()

{

pushScreen (new HttpsConnectionScreen());

}

}

final class HttpsConnectionScreen extends screen

{

public HttpsConnectionScreen()

{

HttpsConnection c = null;

InputStream is = null;

int rc;

try {String url =

"https://192.168.2.3: 8443/cit/j_acegi_security_check? j_username = sanogo & j_password = redhat;

c = (HttpsConnection) Connector.open (url);

c.setRequestMethod (HttpsConnection.POST);

System.out.println ("connection is open with the server");

Get the response code is open the connection,

Send the request and read HTTP response headers.

The headers are stored until asked.

RC = c.getResponseCode ();

System.out.println ("response from the server" + rc);

if (rc! = HttpsConnection.HTTP_OK) {

throw new IOException ("HTTP response code:" + rc);

}

is = c.openInputStream ();

Get the ContentType

The string of type = c.getType ();

The length and process data

int len = (int) c.getLength ();

if (len > 0) {

int actual = 0;

int BytesRead = 0;

byte data = new byte[len]; while ((bytesread! = len) & (real! = - 1)) {

real = is.read (data, bytesread, len - bytesread);

bytesRead += real;

}

} else {}

int ch;

while ((ch = is.read (())! = - 1). {

}

}

} catch (ClassCastException e) { throw new IllegalArgumentException ("not a HTTP URL");}

}

catch (IOException ioe) {}

finally {

Try

{

if (is! = null)

is. Close();

if (c! = null)

c.Close ();

}

catch (IOException ioe) {}

}

}

}

When I run this program in the Simulator, I can do nothing. Please correct me if I'm wrong in coding.

As I am new to this blackberry JDE environment, ideas and suggestions on how to write and run the sample applications in the blackberry are more welcomed.

Concerning

Hinduja

Make sure that your MDS starts when the Simulator starts.  In the JDE will in Edition > Preferences > Simulator > General and click the checkbox "launch Mobile Data System connection with Simulator Service.

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for

  • Ukraine

    I live in Ukraine, today apple Russian support refused to help me. Where can I go?

  • Protection of personal information

    at the first time, using my old phone Samsung Galaxy Verizon SCH-S3 - I535 Skype worked perfectly, but then change my phone for Skype Samsung Galaxy S4 T-Mobile SGH-M919 has now finished with a question. during any kind of calls even call the sound T

  • Photosmart C5200: Printer fails to print

    I can print and copy normal documents, but when I change the text in a document and try to print the computer sends the signal of the poster "Now printing" printer and then stops! I tried to disconnect and reconnect the printer, but it makes no diffe

  • BSOD on reboot after installing the patch MS10-046

    I installed the critical patch MS10-046 on a netbook under XP SP3. On reboot, bsod with error message: "The Shell32.dll image is possibly corrupt. The header checksum does not match the checksum calculated. » The only way to start was via a USB key.

  • Changed the color scheme, but can not change back

    original title: Color and appearance I have inadvertently changed the intensity of the color of my color scheme, now I can't change it back.  The tasks and the text boxes are so pale they appear white against white window.  How can I change this back