Java Programing laungage

J2ME Projects

J2ME Project 1

adplus-dvertising
Create an application to open Web page in Midlet
Previous Home Next

Introduction

In program, a Http request is made form Midlet to JSP (Java Server Page) page which run on Web Server ( Apache Tomcat ) to access web page into Midlet.

Midlet Program


/*
 * Save as a webPageMidlet.java
 */
package r4r.Mobile.Application;

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

/**
 * @author R4R
 */
public class webPageMidlet extends MIDlet implements CommandListener {

    final Command CONNECT = new Command("Connect", Command.OK, 1);
    final Command EXIT = new Command("Exit", Command.EXIT, 2);
    private Form form;

    public webPageMidlet() {
        // declaration field with initialization
        form = new Form("Connect to Web page");
        form.addCommand(CONNECT);
        form.addCommand(EXIT);
        form.setCommandListener(this);
    }

    public void startApp() {
        Display.getDisplay(this).setCurrent(form);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        notifyDestroyed();
    }