Developing Mobile-based E-Voting System





Chapter Two


Developing Mobile-based E-Voting System 

 

 

1.1 Objectives

 

The main
objective of our thesis was to develop a mobile-based voting system. Today,
Electronic-mail, cellular phones etc has diminished the use of telephones.
Someone will agree to take a mobile instead of telephones. Today a person can
carry a laptop with his/her journey instead of desktop while pocket Pcs has
forwarded one step with his compute and communication skill. Typing machine has
got up and its task has implemented as one part of computers. Consumers are
giving up one Technology and using another technology. What has leaded them to
change their choice? Of course, because of the cheaper, easy to use, low power
dissipation, high product power etc has prompted the consumers.

 

In every democratic country, election is a major
issue. For keeping pace with Technology, like other issues election had tried
to take under technology in different time in different country. Then
electronic vote machine was invented.

 

              

              Figure 1.1 Electronic vote machines in
different country

  

Australia, Belgium, Brazil, Canada, Estonia, France,
Germany, India, Ireland, Italy, Nether Lands, Norway, Romania, Switzerland,
England, Scotland already used the e-vote machine in different election. About
Bangladesh, Electronic voting machine is a project, which is in the process of
getting fund from Bangladesh Government. In this project total three members
are working. Our objective is to build an electronic voting machine, which will
increase efficiency of manual voting system. Basically vote-counting part will
be automated in this system, which will save lots of time and money. The
program for the machine has already been developed. Currently the hardware part
of the prototype is building up. Although; it can shorten the labor of thousand
people and has some pros and cons but it will make the voting system more
secure and exact. Another revolutionary change in our country in our
communication is mobile communication.

Considering all
these we feel interested to work in this field.

1.2 Working Environments

1.2.1 Environment

To
develop E-Voting System application (Client/server) first we need to create a
convenient environment. In order to ensure that we use the followings

 

Software: JBuilder X for J2ME as our test writhing
environment. We also use J2sdk1.4.2_12 as a runtime environment and XAMPP for
database system and server system.

 

Simulator: To observe communication between sever (PC) and
client devices using our application as simulation (Sun Java Wireless Toolkit
2.3 beta) is used.

To
understand our work in better the following are explained:

1.2.2 PHP (Hypertext Processor)

PHP is a reflective
programming
language
originally designed for producing dynamic web pages. PHP is used mainly in server-side
scripting
,
but can be used from a command line
interface
or in standalone graphical
applications
. Textual User
Interfaces
can also be created using nurses. PHP is a recursive initialism for PHP: Hypertext
Preprocessor.
PHP
is
an open
source programming language. 

1.2.3 MySQL

MySQL is a multithreaded,
multi-user SQL
database
management system
(DBMS). The basic program runs as a server providing
multiuser access to a number of databases. In our application we use MySQL
database to interact with our program data.

 

1.2.4 Apache Server

The Apache HTTP Server, commonly referred
to simply as Apache, is a
web server notable for playing a key role
in the initial growth of the
World Wide Web. Apache was the first viable
alternative to the
Netscape
Communications Corporation
web server (currently known as Sun Java
System Web Server
), and has since evolved to rival other Unix-based web
servers in terms of functionality and performance. Microsoft Internet
Information Services (IIS) is another web server used in .NET platform. We use
Apache web server.

 

1.2.5 J2SDK 1.4.2_12

 

It is runtime environment for running sun java
Wireless Toolkit2.3Beta.

1.2.6 Sun Java Wireless
Toolkit 2.3 Beta:

The Sun Java Wireless Toolkit (formerly known as
J2ME Wireless Toolkit) is a set of tools for creating Java applications that
run on devices compliant with the Java Technology for the Wireless Industry
(JTWI, JSR 185) specification. It consists of build tools, utilities, and a
device emulator.

 

1.3
Simulator

 

Simulator is a special type to toolkit where we can
experiment our work without the help of physical equipment. In this thesis we
used Sun Java Wireless Toolkit Beta 2.3 version.

 

1.4 The tools in the
Toolkit

 

The
Sun Java wireless Toolkit has three main components:

  • KToolbar automates
    many of the tasks involved in creation MIDP applications.
  • The emulator is a
    simulated mobile phone. It is useful for testing MIDP applications.
  • A collection  of utilities provides other useful
    functionality, including a text messaging console and cryptographic
    utilities [5]

 

1.5 Toolkit Features

 

The Sun Java Wireless Toolkit supports
the creation of MIDP applications with the following main features:

Building
and packaging: You write the source code and the toolkit care of the rest. With
the push of a button, the toolkit complies the source code, preverified the
class files, and packages a MIDlet suite.

Running and monitoring: You can run a  
MIDlet suite directly in the emulator or install it using a process that
resembles application installation on a real device. A memory monitor, network
monitor, and method profiler are provided to analyze the operation of your
MIDlets. MIDlet suite signing: The toolkit contains tools for cryptographically
signing MIDlet sites. This is useful for section the operation of MIDlets in
different protection domains.

 

Mobile
Wireless Technology   

        

2.1 History of Wireless Communications

 

The
first wireless networks were developed in the pre-industrial age. These systems
transmitted information over line-of-sight distances (later extended by
telescopes) using smoke signals, torch signaling, flashing mirrors, signal
flares, or semaphore flags.

Early
radio systems transmitted analog signals. Today most radio systems transmit
digital signals composed of binary bits, where the bits are obtained directly
from a data signal or by digitizing an analog signal. A digital radio can
transmit a continuous bit stream or it can group the bits into packets.

 

Geosynchronous satellites have large coverage areas,
so fewer satellites (and dollars) are necessary to provide wide area or global
coverage. However, it takes a great deal of power to reach the satellite, and
the propagation delay is typically too large for delay-constrained applications
like voice. However, the satellite mobile terminals were much bigger, consumed
much more power, and cost much more than contemporary cellular phones, which
limited their appeal. The most compelling feature of these systems is their
ubiquitous worldwide coverage, especially in remote areas or third-world
countries with no landline or cellular system infrastructure. Unfortunately,
such places do not typically have large demand or the resources to pay for
satellite service either. As cellular systems became more widespread, they took
away most revenue that LEO systems might have generated in populated areas.
With no real market left, most LEO satellite systems went out of business.

 

A natural area for satellite systems is broadcast
entertainment. Direct broadcast satellites operate in the 12-GHz frequency
band. These systems offer hundreds of TV channels and are major competitors to
cable. Satellite-delivered digital radio has also become popular. These
systems, operating in both Europe and the United States, offer digital audio
broadcasts at near-CD quality.

 

2.2
Mobile System

 

            In A View of Mobile Generation

 

                                                  

Figure-2.1

 

The
mobile system can be categorized in the following generations:

 

 

2.2.1
1G (
First Generation)

 

The first handheld mobile phone
to become commercially available to the US market was the
Motorola DynaTAC 8000X, which received approval
in
1983. Mobile phones began to proliferate through the 1980s with the introduction of “cellular”
phones based on
cellular networks with multiple    base stations located relatively close to
each other,
and protocols for the automated
“handover” between two cells when a phone moved from one cell to the
other. At this time
analog transmission was in use in all
systems. Mobile phones were somewhat larger than current ones, and at first,
all were designed for permanent installation in vehicles (hence the term car
phone). Soon, some of these bulky units were converted for use as
“transportable” phones the size of a briefcase. Motorola introduced
the first truly portable, handheld phone. These systems
(NMT, AMPS,
TACS,
RTMI,
C-Netz
, and Radiocom 2000) later became known as first generation (1G) mobile phones.

 

2.2.2 2G(Second Generation)

 

The second generation of mobile telephony systems
uses digital encoding. 2G networks support high bit rate voice,limited data
communications and different levels of encryption. 2G networks include GSM,
D-AMPS (TDMA) and CDMA. 2G networks can support SMS applications.

                

                                                            Figure-2.2

 

In the 1990s, ‘second generation’ (2G) mobile phone systems such as GSM,
IS-136
(“TDMA”), iDEN and IS-95 (“CDMA”) began
to be introduced. The first digital cellular phone call was made in the United States
in
1990, in 1991 the first GSM network (Radiolinja) opened in Finland. 2G phone systems were
characterized by digital circuit switched transmission and the introduction of
advanced and fast phone to network signaling. In general the frequencies used
by 2G systems in Europe were higher though with some overlap, for example the
900 MHz frequency range was used for both 1G and 2G systems in Europe and so
such 1G systems were rapidly closed down to make space for 2G systems. In
America the
IS-54 standard was deployed in
the same band as AMPS and displaced some of the existing analog channels.

 

Coinciding with the introduction of 2G systems was
a trend away from the larger “brick” phones toward tiny 100–200g
hand-held devices, which soon became the norm. This change was possible through
technological improvements such as more advanced batteries and more
energy-efficient electronics, but also was largely related to the higher
density of cellular sites caused by increasing usage levels.

 

 2.2.3 2.5G

 

 2.5G
extends 2G systems, adding features such as packet-switched connection and
enhanced data rates.2.5G networks include EDGE and GPRS. These networks support
WAP, MMS, SMS mobile games, and search and directory.

 

2.2.4 3G(Third Generation)Not
long after the introduction of
2G networks, projects began to develop third
generation (3G) systems. Inevitably there were many different standards
with different contenders pushing their own technologies. Quite differently
from 2G systems, however, the meaning of 3G has been standardized in the
IMT-2000 standardization processing. This process did not standardize on a
technology, but rather on a set of requirements (2 Mbit/s maximum data rate
indoors, 384 kbit/s outdoors, for example). At that point, the vision of a
single unified worldwide standard broke down and several different standards
have been introduced.

 

 During the
development of
3G systems, 2.5G systems such as CDMA2000 1x and GPRS
were
developed as extensions to existing
2G networks. These provide
some of the features of 3G without fulfilling the promised high data rates or
full range of multimedia services. CDMA2000-1X delivers theoretical maximum
data speeds of up to 307 kbit/s. Just beyond these is the
EDGE system which in theory
covers the requirements for
3G
system, but
is so narrowly above these that any practical system would be sure to fall
short.

 

 

2.2.5
4G (Fourth Generation)

 

4G
(or 4-G) is short for fourth-generation cellular communication system. There is
no set definition to what 4G is; however the feature that is predicted for 4G
can be summarized in a single sentence. The 4G will be a fully IP-based
Integrated system of systems and network of networks achieved
after the convergence of wired and wireless networks as well as computer,
consumer electronics, communication technology, and several other convergences
that will be capable of providing 100 Mbps and 1Gbps, respectively, in outdoor
and indoor environments with end-to-end QoS and high security, offering any
kind of services anytime, anywhere, at affordable cost and one billing.

 

The
WWRF (Wireless World Research Forum) defines 4G as a network that operates on
Internet technology, combines it with other applications and technologies such
as Wi-Fi and WiMAX, and runs at speeds ranging from 100 Mbps (in cell-phone
networks) to 1 Gbps (in local Wi-Fi networks).4G is not just one defined
technology or standard, but rather a collection of technologies and protocols
to enable the highest throughput, lowest cost wireless network possible. The
official designation from the IEEE for 4G is beyond 3G.

 

2.3
Mobile architecture

 

2.3.1 GSM System

 

The GSM system is specified in 12 series of specifications. For
phase 1, these specifications constitute over 4000 pages. Although much of the
information in the specifications is redundant, it is impossible for most
people to learn the GSM system from the specifications. It will therefore be
given a short overview of the GSM system in this thesis, as well as the details
necessary to understand the proposed solution to the location problem.

The GSM system consists of a number of separate entities. These
are shown in figure 2.3. The entities are connected through interfaces with
their own names according to the specifications.

\begin{figure}
\centering
\epsfig {file=teori/entiteter.eps, width=14cm}
 \end{figure}

 

Figure 2.3:  Entities
of the GSM system.

These names are
shown on the figure. In the following, each of the different entities will be
described.

2.3.2 The Mobile
Station
(MS)

The Mobile
Station (MS) is the user equipment in GSM. The MS is what the user can see of
the GSM system, the cellular phone itself. Production of Mobile Stations is
done by many different manufacturers, and there will almost always be a wide
range of different Mobile Stations in a mobile network.

The MSs in GSM
are independent from networks-providers. The identity of the subscriber is
obtained from a SIM (Subscriber Identity Module) that has to be inserted into
the MS to make it work. The SIM contains the IMSI (International Mobile
Subscriber Identity) which uniquely intensifies the subscriber to the network.
It also contains information necessary to encrypt the connections on the radio
interface.

2.3.3 The Base
Transceiver Station
(BTS)

The Base
Transceiver Station (BTS) is the entity corresponding to one site communicating
with the Mobile Stations. Usually, the BTS will have an antenna with several
TRXs (radio transceivers) that each communicate on one radio frequency. The
link-level signaling on the radio-channels is interpreted in the BTS, whereas
most of the higher-level signaling is forwarded to the BSC and MSC .

2.3.4 The Base
Station Controller
(BSC)

Each Base
Station Controller (BSC) controls the magnitude of several hundred BTSs. The
BSC takes care of a number of different procedures regarding call setup,
location update and handover for each MS. It is the BSC that decides when
handover is necessary. This is accomplished by analyzing the measurement
results that are sent from the MS during a call and ordering the MS to perform
handover if this is necessary.

2.3.5 The Mobile
Switching Centre
(MSC)

The Mobile
Switching Centre (MSC) is a normal ISDN-switch with extended functionality to
handle mobile subscribers. The basic function of the MSC is to switch speech
and data connections between BSCs, other MSCs, other GSM-networks and external
non-mobile-networks.

2.3.6 The
Location Registers

With each MSC,
there is associated a Visitors Location Register (VLR). The VLR can be
associated with one or several MSCs. The VLR stores data about all customers
who are roaming within the location area of that MSC. This data is updated with
the location update procedure initiated from the MS through the MSC, or
directly from the subscriber Home Location Register (HLR). The HLR is the home
register of the subscriber. Subscription information, allowed services,
authentication information and localization of the subscriber are at all times
stored in the HLR.The communication between MSC, VLR and HLR is done using the
MAP (Mobile Application Part) of the Signaling System .

2.3.7 The
Equipment Identity Register
(EIR) 

The Equipment
Identity Register (EIR) is an optional register. Its purpose is to register
IMEIs of mobile stations in use. By implementing the EIR the network provider
can blacklist malfunctioning MSs or even receive reports to the operations
centre when stolen mobile stations are used to make calls.

2.4 Architecture of the GSM Network

A GSM network is
composed of several functional entities, whose functions and interfaces are
specified. Figure 1.1 shows the layout of a generic GSM network. The GSM
network can be divided into three broad parts. The subscriber carries the
Mobile Station. The Base Station Subsystem controls the radio link with the
Mobile Station. The Network Subsystem, the main part of which is the Mobile
services Switching Center (MSC), performs the switching of calls between the
mobile users, and between mobile and fixed network users. The MSC also handles
the mobility management operations. Not shown is the Operations and Maintenance
Center, which oversees the proper operation and setup of the network. The
Mobile Station and the Base Station Subsystem communicate across the Um
interface, also known as the air interface or radio link. The Base Station
Subsystem communicates with the Mobile services Switching Center across the A
interface.

Figure
2.4: General architecture of a GSM network

2.4.1 Mobile Station

The mobile
station (MS) consists of the mobile equipment (the terminal) and a smart card
called the Subscriber Identity Module (SIM). The SIM provides personal
mobility, so that the user can have access to subscribed services irrespective
of a specific terminal. By inserting the SIM card into another GSM terminal,
the user is able to receive calls at that terminal, make calls from that terminal,
and receive other subscribed services.

The
International Mobile Equipment Identity (IMEI) uniquely identifies the mobile
equipment. The SIM card contains the International Mobile Subscriber Identity
(IMSI) used to identify the subscriber to the system, a secret key for
authentication, and other information. The IMEI and the IMSI are independent,
thereby allowing personal mobility. The SIM card may be protected against
unauthorized use by a password or personal identity number.

2.4.2
Base Station Subsystem

The Base Station
Subsystem is composed of two parts, the Base Transceiver Station (BTS) and the
Base Station Controller (BSC). These communicate across the standardized Abis
interface, allowing (as in the rest of the system) operation between components
made by different suppliers.

The Base
Transceiver Station houses the radio transceivers that define a cell and
handles the radio-link protocols with the Mobile Station. In a large urban
area, there will potentially be a large number of BTSs deployed, thus the
requirements for a BTS are ruggedness, reliability, portability, and minimum
cost.

The Base Station
Controller manages the radio resources for one or more BTSs. It handles
radio-channel setup, frequency hopping, and handovers, as described below. The
BSC is the connection between the mobile station and the Mobile service
Switching Center (MSC).

2.4.3
Network Subsystem

The central
component of the Network Subsystem is the Mobile services Switching Center
(MSC). It acts like a normal switching node of the PSTN or ISDN, and
additionally provides all the functionality needed to handle a mobile
subscriber, such as registration, authentication, location updating, handovers,
and call routing to a roaming subscriber. These services are provided in
conjunction with several functional entities, which together form the Network
Subsystem. The MSC provides the connection to the fixed networks (such as the
PSTN or ISDN). Signaling between functional entities in the Network Subsystem
uses Signaling System Number 7 (SS7), used for trunk Signaling in ISDN and
widely used in current public networks.

The Home
Location Register (HLR) and Visitor Location Register (VLR), together with the
MSC, provide the call-routing and roaming capabilities of GSM. The HLR contains
all the administrative information of each subscriber registered in the
corresponding GSM network, along with the current location of the mobile. The
location of the mobile is typically in the form of the Signaling address of the
VLR associated with the mobile station. The actual routing procedure will be
described later. There is logically one HLR per GSM network, although it may be
implemented as a distributed database.

The Visitor
Location Register (VLR) contains selected administrative information from the
HLR, necessary for call control and provision of the subscribed services, for
each mobile currently located in the geographical area controlled by the VLR.
Although each functional entity can be implemented as an independent unit, all
manufacturers of switching equipment to date implement the VLR together with
the MSC, so that the geographical area controlled by the MSC corresponds to
that controlled by the VLR, thus simplifying the Signaling required. Note that
the MSC contains no information about particular mobile stations this
information is stored in the location registers.

The other two
registers are used for authentication and security purposes. The Equipment
Identity Register (EIR) is a database that contains a list of all valid mobile
equipment on the network, where its International Mobile Equipment Identity
(IMEI) identifies each mobile station. An IMEI is marked as invalid if it has
been reported stolen or is not type approved. The Authentication Center (AuC)
is a protected database that stores a copy of the secret key stored in each
subscriber’s SIM card, which is used for authentication and encryption over the
radio channel.

2.5
Handoff

In cellular telecommunications, the term handoff
refers to the process of transferring an ongoing call or data session from one
channel connected to the core network to another. In
satellite
communications
it is the process of transferring satellite control
responsibility from one
earth
station
to another without loss or interruption of service. The British English term for transferring a
cellular call is handover, which is the terminology standardised by
3GPP within such European originated
technologies as
GSM and UMTS.

Reason of
conduction

In telecommunications there may be different reasons why a handoff
(handover) might be conducted:

·        
When the phone is moving away from the area covered by
one cell and entering the area covered by another cell the call is transferred
to the second cell in order to avoid call termination when the phone gets outside
the range of the first cell

·        
When the capacity for connecting new calls of a given
cell is used up and an existing or new call from a phone, which is located in
an area overlapped by another cell, is transferred to that cell in order to
free-up some capacity in the first cell for other users, who can only be
connected to that cell;

Figure 2.5:
Handoff System

  • In non-CDMA networks when the
    channel used by the phone becomes interfered by another phone using the
    same channel in a different cell, the call is transferred to a different
    channel in the same cell or to a different channel in another cell in
    order to avoid the interference;
  • Again in non-CDMA
    networks when the user behaviour changes, e.g. when a fast-travelling
    user, connected to a large, umbrella-type of cell, stops then the call may
    be transferred to a smaller
    macro cell or even to a micro cell in order to free
    capacity on the umbrella cell for other fast-travelling users and to
    reduce the potential interference to other cells or users (this works in
    reverse too, when a user is detected to be moving faster than a certain
    threshold, the call can be transferred to a larger umbrella-type of cell
    in order to minimise the frequency of the handoffs due to this movement);
  • In CDMA networks a soft handoff (see further down) may be
    induced in order to reduce the interference to a smaller neighbouring cell
    due to the “
    near-far effect even when
    the phone still has an excellent connection to its current cell,etc.

Kinds of handoff

The most basic form of handoff (handover) is when
a
phone call in progress is
redirected from its current
cell (called source) and its used channel
in that cell
to a new cell (called target) and a new channel. In terrestrial networks
the source and the target cells may be served from two different cell sites or
from one and the same cell site (in the latter case the two cells are usually
referred to as two sectors on that cell site). Such a handoff, in which
the source and the target are different cells (even if they are on the same
cell site) is called inter-cell handoff. The purpose of inter-cell
handoff is to maintain the call as the subscriber is moving out of the area
covered by the source cell and entering the area of the target cell.

 

 A special
case is possible, in which the source and the target are one and the same cell
and only the used channel is changed during the handoff. Such a handoff, in
which the cell is not changed, is called intra-cell handoff. The purpose
of intra-cell handoff is to change one channel, which may be interfered or
fading with a new clearer or less fading channel.

 

i. Hard Handoff

A hard handoff is one in which the channel in the
source cell is released and only then the channel in the target cell is
engaged. Thus the connection to the source is broken before the connection to
the target is made — for this reason such handoffs are also known as break-before-make.
Hard handoffs are intended to be instantaneous in order to minimise the disruption
to the call. A hard handoff is perceived by network engineers as an event
during the call.

 

 

 

ii.Soft Handoff

A soft handoff is one in which the channel in
the source cell is retained and used for a while in parallel with the channel
in the target cell. In this case the connection to the target is established
before the connection to the source is broken, hence this handoff is called make-before-break.
The interval, during which the two connections are used in parallel, may be
brief or substantial. For this reason the soft handoff is perceived by network
engineers as a state of the call, rather than a brief event. A soft handoff may
involve using connections to more than two cells, e.g. connections to three,
four or more cells can be maintained by one phone at the same time. When a call
is in a state of soft handoff the signal of the best of all used channels can
be utilised for the call at a given moment or all the signals can be combined
to produce a clearer copy of the signal. The latter is more advantageous, and
when such combining is performed both in the
downlink (forward link) and the uplink (reverse link) the handoff is termed as softer.
Softer handoffs are possible when the cells involved in the handoff have a
single cell site.

 

Advantages and Disadvantages

 

An advantage of the hard handoff is that at any
moment in time one call uses only one channel. The hard handoff event is indeed
very short and usually is not perceptible by the user. In the old
analog systems it could be
heard as a click or a very short beep, in digital systems it is unnoticeable.
Another advantage of the hard handoff is that the phone’s hardware does not
need to be capable of receiving two or more channels in parallel, which makes
it cheaper and simpler. A disadvantage is that if a handoff fails the call may
be temporarily disrupted or even terminated abnormally. Technologies, which
utilise hard handoffs, usually have procedures which can re-establish the
connection to the source cell if the connection to the target cell cannot be
made. However re-establishing this connection may not always be possible (in
which case the call will be terminated) and even when possible the procedure
may cause a temporary interruption to the call.

One advantage of the soft handoffs is that the connection to the source
cell is broken only when a reliable connection to the target cell has been
established and therefore the chances that the call will be terminated
abnormally due to a failed handoff are lower. However, by far a bigger
advantage comes from the mere fact that simultaneously channels in multiple cells
are maintained and the call could only fail if all of the channels are
interfered or fade at the same time. Fading and interference in different
channels are unrelated and therefore the probability of them taking place at
one the same moment in all channels is very low. Thus the reliability of the
connection becomes higher when the call is in a soft handoff. Because in a
cellular network the majority of the handoffs occur in places of poor coverage,
where calls would frequently become unreliable when their channel is interfered
or fading, soft handoffs bring a significant improvement to the reliability of
the calls in these places by making the interference or the fading in a single
channel not critical. This advantage comes at the cost of more complex hardware
in the phone, which must be capable of processing several channels in parallel.
Another price to pay for soft handoffs is use of several channels in the
network to support just a single call. This reduces the number of remaining
free channels and thus reduces the capacity of the network. By adjusting the
duration of soft handoffs and the size of the areas, in which they occur, the
network engineers can balance the benefit of extra call reliability against the
price of reduced capacity.

J2ME
Wireless Technology

 

3.1
Overview of J2ME

 

Unlike
J2SE, J2ME is not a piece of software, nor is it a single specification. This
difference can be confusing, even for developers who are already familiar with
J2SE. Instead, J2ME is a platform, a collection of technologies and
specifications that are designed for different parts of the small device
market. Because J2ME spans such a variety of devices, it wouldn’t make sense to
try to create a one-size-fits-all solution.

 

J2ME
is a highly optimized Java runtime environment. J2ME is aimed at the consumer
and embedded devices market. This includes devices such as cellular telephones,
Personal Digital Assistants (PDAs) and other small devices.

 

                                                   

                             Figure 3.1 High level view of J2ME

 

Java
2 Standard Edition (J2SE) developers should be familiar with Java Virtual
Machines (JVMs) and at least one host Operating System (OS).

 

During
the development of their new Java 2 platform Sun recognized in 1999 that they
had to cut back from their motto “compile once, run everywhere”(even though
this wasn’t true beforehand and afterwards surely also not) and decided to
split up this new version of Java in three distinct parts:

Java
2 Enterprise Edition (J2EE). For enterprises with a need to serve

their
suppliers, customers and employees with Internet business server

Solutions.

Java
2 Standard Edition (J2SE). For the well-established desktop market and Internet
applications.

Java
2 Micro Edition (J2ME). For consumer and embedded device manufacturers who
build many really divers kinds of information devices, service providers who
wish to deliver content to their customers over those devices, and content
creators for small, resource-constrained devices.

 

                         Figure 3.2 Fragmentation of Java 2

 

Even
so, the problem Sun had to face with the Micro Edition was that there were
entirely different run time environments among the target platforms.

Devices
for J2ME could be:

With
/ without keyboard.

With
/ without display (grayscale / color).

With
/ without network interface (LAN, WAN, Internet).

Memory
from some few 10kByte up to 16Mbyte.

 

The
method of resolution chosen was the “device profile”, specifying a

minimum
of Java classes for each class of devices. Like it’s bigger brothers,

Java
2 Micro Edition aims at maintaining the basic features that Java

technology
boasts:

Built-in
consistency across products in terms of running anywhere, any

time,
on any device.

The
power of a high-level object-oriented programming language with a

large
developer base.

Portability
of code.

Safe
network delivery.

Upward
scalability with J2SE and J2EE.

At
the higher level, J2ME is targeted at two distinct groups of products (see

Figure
3.2):

Personal,
mobile, connected information devices. E.g. Personal organizers, Cell
phones or pagers.

Shared,
fixed, connected information devices. E.g. Internet TVs, screen Phones,
high-end communicators or car entertainment/navigation Systems.

 

As
always is the case when distinguishing, the border between these two Product
groups

are
fluid. To address the inherent diversity of the Java 2 Micro Edition market, an
essential requirement is not only small size but also modularity and customizability.
Because of this, the Java 2 Micro Edition architecture was made modular and
scalable to support this kind of flexible deployment demanded by the target
markets, which in this case are the rapidly growing consumer and embedded
markets.

 

For
lower-end, resource-limited products (compared to normal personal Computers),
Java

2
Micro Edition supports minimal configurations of the Java virtual machine and
Java APIs that provide and capture just the essential capabilities of each kind
of device. As device manufacturers add new features to their devices, or
service providers develop new and exciting applications, these configurations
will be expanded with additional APIs or with a richer complement of Java
virtual machine features. To support this kind of customizability and
extensibility, the two essential concepts of configurations and profiles were
defined.

 

New
Configurations and profiles are created by an open process for defining

new
additions to Java called “Java Community Process” (JCP).

 

3.2
Configurations of J2ME

 

The
J2ME platform covers a large range of different devices types. Devices like TV
set-top boxes, Internet TVs and high-end communicators have a large range of
user interface capabilities and memory budgets in range of 2 to 16megabytes as
well. On the other hand devices like simple mobile phones, pagers and personal
organizers have a very simple user interface and low-level memory budget. Due
to the large range of different type devices in the J2ME market place, Sun has
split the Java 2 Micro Edition in configurations. Configurations define
virtual machines features, Java language features and Java API classes for each
configuration environment. A J2ME configuration defines a minimum platform for
a “horizontal” class or family of devices, each with similar requirements on
total memory budget and processing power. A configuration defines the Java
language and virtual machine features and minimum libraries that a J2ME
supported device manufacturer or a content provider can expect to be available on
all devices of the same class. To avoid fragmentation that could lead to
confusion, Sun has introduced until now only two configurations, which are:

 

3.3 CLDC

 

Connected Limited Device
Configuration

Very
simple user interface (including no UI at all)

Low
level memory budgets (160 kB to 512 kB)

16
or 32 bit processors

Wireless
communication, possibly low bandwidth

Limited
power, often battery operation.

Examples:
Mobile phones, pagers and personal organizers.

 

The
CLDC was the first configuration to be defined as it is bound to the main
target group: small toys or gadgets, which always are carried around by the
user, e.g. mobile phones or PDAs. So the market consisting of personal, mobile,
connected information devices is served by the CLDC. This configuration
includes some new classes, not drawn from the J2SE APIs, designed specifically
to fit the needs of small-footprint devices

                                                 Figure-3.3

 

3.4 CDC: Connected Device
Configuration

 

Large range
of user interface capabilities (down to and including no UI)

Memory
budgets in range of 2 to 16 megabytes.

16
or 32 bit processors

Connectivity
to some type of network

Examples:
TV set-top boxes, Internet TVs and high-end communicators

 

The
relationship between CDC, CLDC and Java 2 Standard Edition is illustrated in
Figure 3.3. As shown there, the main functionality in CDC and CLDC is inherited
from the J2SE. All the classes which are inherited from the J2SE are precisely the
same or a subsets of the corresponding classes in the J2SE and the classes
which are outside the J2SE environment may not use the java.* class names.
Thus, upward compatibility is achieved between the different editions of Java 2
platforms. All features implemented in the CLDC are also implemented in the CDC
to achieve upward compatibility between J2ME configurations as well. Thus, all
applications implemented for the Connected Limited Device Configuration
platform can be run in the connected Device Configuration platform as well.

 

The CDC serves the market
consisting of shared, fixed, connected Information devices. To ensure upward
compatibility between configurations, the CDC is a superset of the CLDC (see
Figure 3.3).

 

3.5
Profiles

The configurations help
already a lot to distinguish different types of devices. But as there so many
types around they still have to be refined further because a configuration
might cover devices intended for totally different usage, like mobile phones
and refrigerators, or washing machines and set-top boxes. The mobile phone and
e.g. a washing machine could belong to the same configuration but it is obvious
that a mobile phone application is not expected to run on the washing machine
or vice versa. Thus, the J2ME framework provides the concept of a profile to
achieve application environment portability. A J2ME profile addresses the
specific demands of a certain “vertical” market segment (e.g. banking or
payment applications) or device category. Because of this, profiles may include
libraries that are far more device category specific than the libraries
provided in a configuration. Profiles are implemented on top of a
configuration. Applications then are written for a specific profile, as
profiles are assembled for a specific configuration. Both profiles and
configurations define a set of Java API classes which can be used by the
applications. A device that is designed to support a profile or several
profiles, agrees to implement all features and Java API classes which are specified
by the profile(s) and corresponding configuration. From an implementation
viewpoint, a profile is just a collection of Java API and class libraries
residing on top of a configuration and providing domain specific capabilities
for devices in a specific market segment.

 

3.6 MIDP: Mobile information device profile (on top
of CLDC)

 

By building upon the CLDC,
this profile will provide a standard platform for small, resource-limited,
wireless-connected mobile information devices like cellular phones and two-way
pagers. In addition to being wireless-connected, these devices have small
displays, limited input devices, limited local storage, battery life, and CPU
power. Two types of devices will be accommodated: Mobile information appliances
and voice communication devices.


Figure 3.4
MIDP position in J2ME architecture

 

 

                                

                

 

3.6.1
MIDP version 1

The
MIDP version 1.0a is the result of the work carried out by a Java Community
Process expert group, JSR 37, consisting of a number of industrial partners.
The MIDP 1.0a specification defines the architecture and the associated APIs
needed for application development for mobile information devices. The MIDP
targets MIDs.

 

 To be classified as a MID, a device should
have the minimum characteristics listed in Table 3.1:

 

Display

Pixels:
96×54

Display
depth

1-bit

Pixel
shape (aspect ratio)

Approximately

Input

One-
or two-handed keyboard or touch screen

 

 

Memory

128
KB of non-volatile memory for the MIDP components

 

8
KB of non-volatile memory for application created

persistent
data

 

32
KB of volatile memory for the Java runtime

Environment

Networking

Two-way,
wireless, possibly intermittent, with

limited
bandwidth

                      

                      Table 3.1 MIDP 1.0
requirements

 

The
MIDP adds a few packages on top of the CLDC, shown in Table 3.2

                

  Table3.2
MIDP 1.0 packages

Package

Provides

javax.microediton.lcdui

Provides
classes for user interface

 

javax.microedition.midlet

Defines
MIDP applications and the  interactions
between the application and the environment in which the application runs

 

javax.microedition.rms

Provides
persistent storage (Record Management

System)

 

Since
these packages are added on top of the CLDC, the MIDP API will also include all
CLDC packages. It is worth noting that the MIDP adds a few extra interfaces and
classes to existing packages in the CLDC. One of these is the Http Connection
interface which gives a framework for HTTP connections, by extending the
functionality in the GCF. The Timer Task class in java.util is another example.
Developers should therefore use the MIDP API when programming for MIDs, thus
having access to all classes and interfaces provided by both the CLDC and the
MIDP.

 

Application
management in terms of fetching, installing, selecting, running and removing
MIDlets is not specified by the MIDP 1.0a. These issues are handled by the
Application Manager, which is implemented in a device specific way by the OEM.
Hence, application management is handled in a device specific way. Note that
application management is specified in the new MIDP 2.0 specification.

 

The
MIDP 1.0 relies on the security model of the CLDC and specifies no additional
security features except the semantics implied by the MIDP application model.
The CLDC security model takes care of sufficient low-level and
application-level security. Hence, neither the CLDC nor the MIDP 1.0a addresses
end-to-end security. This was first introduced in MIDP 2.0.

 

3.6.2
MIDP version 2

 

The
MIDP version 2.0 is the result of the Java Community Process expert group JSR-
118. The MIDP 2.0 specification defines an enhanced architecture and the
associated APIs needed for application development for mobile information
devices. The specification is based on the MIDP 1.0 specification, providing
backwards compatibility so that MIDlets written for MIDP 1.0 can execute in
MIDP 2.0

 

 

 

Table
3.3 MIDP 2.0 requirements

 

Display:

Pixels:
96×54

Display
depth

1-bit

Pixel
shape (aspect ratio)

approximately
1:1

Input

One-
or two-handed keyboard or touch screen

 

 

 

Memory

256
KB of non-volatile memory for the MIDP components

8
KB of non-volatile memory for application-created persistent data

128
KB of volatile memory for the Java runtime Environment

Networking:

Two-way,
wireless, possibly intermittent,      with limited bandwidth

Sound:

The
ability to play tones, either via dedicated hardware or via software
algorithm

 

Table
4.4 shows that requirements for display, input and networking are the same as
for MIDP 1.0. Memory requirements have been raised in the MIDP 2.0
specification. There must be 256 KB of non-volatile memory for the MIDP
implementation, beyond what is required for the CLDC and 128 KB of volatile
memory for the Java runtime. Requirements for sound have been added. The
ability to play tones is now made a requirement.

 

MIDP
2.0 is backwards compatible with MIDP 1.0; hence it provides all functionality
defined in the MIDP 1.0 specification. In addition it provides Over-The-Air
(OTA) provisioning. This feature was left to OEMs to provide in the MIDP 1.0
specification. An enhanced user interface has been defined, making applications
more interactive and easier to use. Table 4.5 shows the packages provided by
MIDP 2.0.

 

Package

Provides

Javax.microedition.lcdui

Provides
classes for user interface

 

Javax.microedition.midlet

Defines
MIDP applications and the interactions between the application and the
environment in which the application runs

Javax.microedition.rms

Provides
persistent storage (Record Management System)

Javax.microedition.lcdui.game

Provides
functionality useful for game development

Javax.microedition.media

Provides
the Audio Building Block (ABB)

Javax.microedition.pki

Provides
functionality for handling certificates

 

Table
4.5 MIDP 2.0 packages

Media
support has been added through the ABB, giving developers the ability to add
tones, tone sequences and WAV files even if the Mobile Media API (MMAPI)
optional package is not available. Game developers now have access to a Game
API providing a standard foundation for building games. This API takes
advantage of native device graphic capabilities.

 

3.7 MIDlets

 

MIDP
applications are called MIDlets. Even though Figure 4.4 defines MIDlets as
applications built using the MIDP and CLDC only, one usually also refer to
OEM-specific applications as MIDlets. MIDlets are usually distributed in MIDlet
suites, available on the Internet through WAP.

 

                             

 

Figure 3.5 MIDlet architecture overview

 

The
MIDP defines an application model to allow the limited resources of the device
to be shared by multiple MIDlets. The application model defines the following:

 * What a MIDlet is

 * How it is packaged

 * Runtime environment available to the MIDlet

 * The MIDlet’s behavior so that the device can
manage its resources

 * Packaging of MIDlets forming a MIDlet-suite

 

3.7.1
Structure of Bluetooth MIDlet

This
section shows the structure in a Java/Bluetooth MIDlet. Several MIDlet examples
are available on Sun Microsystems’ Mobility website.

Usually
an event-driven MIDlet with no Bluetooth support looks like this:

import
javax.microedition.lcdui.Command;

import
javax.microedition.lcdui.CommandListener;

import
javax.microedition.lcdui.Displayable;

import
javax.microedition.midlet.MIDlet;

public
class YourMidlet extends MIDlet implements CommandListener

 

public
void startApp()

 

public
void pauseApp()

 

public
void destroyApp(boolean unconditional)

 

public
void commandAction(Command c, Displayable d)

 

 

The
first three methods, startApp (), pauseApp ( ) and destroyApp () are needed for
any MIDlet. They come from extending the MIDlet class. The next method,
commandAction() comes from the CommandListener interface. This is needed to
catch command events. The MIDlet is extended to support Bluetooth communication
in the next code sample. During device discovery and service discovery, events
will be delivered to a DiscoveryListener object when devices or services are
found or the device discovery or service discovery is completed. An object
implementing the DiscoveryListener interface is used to catch these events.

 

The
MIDlet will then look like this:

import
javax.bluetooth.DiscoveryListener;

import
javax.bluetooth.DeviceClass;

import
javax.bluetooth.ServiceRecord;

import
javax.bluetooth.RemoteDevice;

import
javax.microedition.lcdui.Command;

import
javax.microedition.lcdui.CommandListener;

import
javax.microedition.lcdui.Displayable;

import
javax.microedition.midlet.MIDlet;

public
class YourMidlet extends MIDlet implements CommandListener,

DiscoveryListener

 

public
void startApp()

 

public
void pauseApp()

 

public
void destroyApp(boolean unconditional)

 

public
void commandAction(Command c, Displayable d)

 

public
void deviceDiscovered(RemoteDevice remoteDevice,

DeviceClass
deviceClass)

 

public
void inquiryCompleted(int param)

 

public
void serviceSearchCompleted(int transID, int respCode)

 

public
void servicesDiscovered(int transID,

 

ServiceRecord[]
serviceRecord)

 

The
last four methods, deviceDiscovered(), inquiryCompleted(),
erviceSearchCompleted() and servicesDiscovered () are used to catch events
during device discovery and service discovery.

 

3.8 Midlets life cycle

 

All
MIDlets are derived from the abstract base class javax.microedition.midlet.MIDlet,
which contains methods that the MIDP platform calls to control the MIDlet’s
lifecycle, as well as methods that the MIDlet itself can use to request a
change in its state. A MIDlet must have a public default constructor (that is,
a constructor that requires no arguments), which may be one supplied by the
developer if there is any initialization to perform or, when there are no
explicit constructors, the empty default constructor inserted by the Java
compiler. This is what a skeleton MIDlet class might look like:

public class MyMIDlet extends
MIDlet

    // Optional constructor

    MyMIDlet

 

protected void startApp throws
MIDletStateChangedException

 

protected void pauseApp(  ) {}

 

protected void destroyApp(boolean
unconditional)

  

throws
MIDletStateChangedException { }

 

At
any given time, a MIDlet is in one of three states: Paused, Active, or
Destroyed. A state diagram that shows how these states are related and the
legal state transitions is shown in Figure 3.6.

 

Diagram.



Figure 3.6. The lifecycle of a MIDlet.

 

When
a MIDlet is loaded, it is initially in the Paused state. The usual class and
instance initialization is then performed–that is, static initializers are
called the first time the MIDlet class is loaded, all instance initializers are
invoked when the MIDlet instance is created, and its public, no-argument
constructor is then invoked. If the MIDlet throws an exception during the
execution of its constructor, the MIDlet is destroyed. If the MIDlet does not
throw an exception, it is scheduled for execution at some later time. Its state
is changed from Paused to Active, and its startApp( ) method is called. The MIDlet class
declares this method as follows:
protected void startApp(  ) throws
MIDletStateChangeException;

 

That
this method is abstract means that you must implement it in your MIDlet, and
that it is protected implies that it will be called either from the MIDlet
class itself or from another class in the javax.microedition.midlet package. In the
reference implementation, the MIDlet lifecycle methods are called from a class
in this package called Scheduler,
but there is nothing in the MIDP specification that requires this class be
used. Licensees may provide their own scheduler implementations, provided that
it supports the MIDlet lifecycle as described in this section. It is very
common for MIDlet developers to redefine the startApp( ) method as public, which is
certainly a safe option, but this should not be necessary because vendor
implementations must continue to work even if these methods are declared as
protected.

 

The
startApp( ) method may
complete normally, in which case the MIDlet is allowed to run, or it may inform
the MIDP platform that the MIDlet does not want to run at this point. There are
several ways to achieve the latter:

 

If
the startApp( ) method detects
an error condition that stops it from completing, but which might not exist
later (i.e., a transient error condition), it should throw a MIDletStateChangeException.
This moves the MIDlet back to the Paused state, so that another attempt to
start it can be made later.

 

If
the startApp( ) method detects
an error condition from which recovery is likely never to be possible (a
nontransient error condition), it should call its notifyDestroyed(
)
method, which is described a little later.

 

Finally,
the MIDlet may throw an exception other than MIDletStateChangeException,
either deliberately or because a method that it invokes throws the exception,
and the startApp( ) method does
not catch it. In this case, it is assumed that a fatal error has occurred, and
the MIDlet is destroyed by calling its destroyApp(
)
method (described later).If the MIDlet does none of these
things, it is in the Active state and will be allowed to run until it is either
paused or destroyed. A MIDlet returns after completing its startApp(
)
method, and it does not have a method that contains the main
logic to which control could be passed, so where is the MIDlet’s code placed?
Usually, a MIDlet has a user interface and executes code as a result of events
generated by key presses or pointer movements. MIDlets can also start separate
background threads to run code that does not depend on the user interface, or
they can use a timer to schedule work periodically, as will be shown later. If
you take these approaches, it is important to manage the background threads
and/or timers appropriately when the MIDlet itself is paused or destroyed.

 

At
any time, the MIDP platform can put a MIDlet into the Paused state. On a cell
phone, for example, this might happen when the host software detects an
incoming call and needs to release the phone’s display so the user can answer
the call. When a MIDlet is paused, its pauseApp(
)
method is called:   protected
abstract void pauseApp(  );

 

As
with startApp( ), a MIDlet is
required to provide an implementation for this method. The appropriate response
to this state change depends on the MIDlet itself, but, in general, it should
release any resources it is holding and save the current state so it can
restore itself when it is reactivated later.

 

3.9 Foundation Profile (on top of CDC)

The Foundation Profile
serves two purposes. It provides a profile of the Java 2 Platform suitable for
devices that need support for a rich network enabled Java environment, but do
not require a graphical user interface. Second, it will provide a base profile
for inclusion by other profiles that need to build on the functionality it
provides by adding graphical user interfaces or other functionality.

 

3.10 Personal Profile (CDC, successor to Personal
Java)

 

Other profiles

RMI profile (on top of
Foundation Profile and CDC):

Provides interoperability
with J2SE RMI.

PDA Profile (on top of
CLDC)

 

3.11
J2ME packages

The
J2ME environment introduces a number of Java packages. These are almost
exclusively placed into the package javax.microedition. The few exceptions are
technologies that could be used in one or more other editions of the Java
platform as well. For example, because you might use Bluetooth technology in
either J2ME or J2SE, the Java APIs for Bluetooth specification (JSR 82) uses
the package names javax.bluetooth and javax.obex.

 

The
table shows the package names specified by the J2ME JSRs, as defined by the
Java Community Process (JCP). It includes only JSRs that are in the final,
public review, proposed final, and public review states, as defined by JCP.
Packages that have been adopted from other Java technologies are not shown. For
instance, CLDC 1.0 (JSR 30) includes items from the java.lang, java.io and
java.util packages.

 

 

3.11.1
J2ME Package Names by JSR Number  

 

JSR               Name                                                  
Package Name

 

1                   Realtime                                               javax.realtime

30                 CLDC1.0                                             
javax.microedition.io

36                 CDC 1.0                                              
javax.microedition.io

37                 MIDP 1.0                                             javax.microedition.io

                                                                                 
javax.microedition.lcdui

                                                                                 
javax.microedition.midlet

                                                                                
javax.microedition.rms

62                
Personal Profile                                 
javax.microedition.xlet

                                                 
                               javax.microedition.xlet.

                                                                                           
ixc

75                 PDA Optional                                    
javax.microedition.pim

                                                                                 javax.microedition.file

80¹                USB API                                           
java.usb

82                 Bluetooth                                           
javax.bluetooth

                                                                               
javax.obex

113²              Speech API                                       
javax.speech

118               MIDP 2.0                                          
javax.microedition.io

                                                                               
javax.microedition.lcdui

                                                                               
javax.microedition.game

                                                                                javax.microedition.media

                                                                               
javax.microedition.media.

                                                                            
                 control

                                                                              
javax.microedition.midlet

                                                                              
javax.microedition.pki

                                                                               javax.microedition.rms

120               WMA 1.0                                         
javax.microedition.io

                                                                              
javax.wireless.messaging

129               Personal Basis Profile                       javax.microedition.xlet

                                                                              
javax.microedition.xlet.

                                               
                                                        ixc

135               MMAPI 1.0                                      
javax.microedition.media

                                                                              
javax.microedition.media.

                                                                                               
control

                                                                              
javax.microedition.media.

                                                                                             protocol

139               CLDC 1.1                                         
javax.microedition.io

177               Security and Trust Services
API       javax.microedition.apdu

                                                                               javax.microedition.jcrmi

                                                                              
javax.microedition.pki

                                                                             
 javax.microedition.

                                                                                            
securityservice

                                                                              
javax.microedition.io

                                                                               javacard.framework

                                                                              
javacard.framework.service

                                                                            
  javacard.security

179              Location API                                    
javax.microedition.location

180              SIP API                                            
javax.microedition.sip

184              Mobile 3D Graphics API                  javax.microedtion.m3g

195              Information Module Profile j            avax.microedition.io

                                                                              
javax.microedition.midlet

                                                                               javax.microedition.rms

205              
WMA 2.0                                         
javax.microedition.io

                                                                              
javax.wireless.messaging

211³             Content handler API                         
javax.microedition.content

226¹             Scalable 2D Vector Graphics
API     javax.microedition.m2d

234¹             Advanced Multimedia                       javax.microedition.media

                                  Supplements 

                                                                              
javax.microedition.media.

                                                                                                          
control                                                                                          

                                                                              
javax.microedition.media.

                                                   
                                           control.audio3d

                                                                              
javax.microedition.media.

                                                                              
control.audioeffect

                                                                              
javax.microedition.media.

                                                                              
control.camera

                                                 
                             javax.microedition.media.

                                                                              
control.imageeffect

                                                                              
javax.microedition.media.

                                                                              
control.tuner

 

Database
Access

4.1
Storing Data

Whenever
we start work on a data–driven application, one of the first design decisions
we have to make is this: What‘s the best data store to use? In other words, how
and where is the application going to store and access its data? The correct
choice is always going to depend on the application’s requirements.

 

We
are probably familiar with the term data because we use data in everyday life,
such as when you dial a telephone or log into a computer networking using user
ID and password. The telephone number, user ID, and password are types of data.
Yet the term data is commonly confused with the term information. Although
these terms have a similar meaning in the vernacular, they are different when
related to a DBMS. Information consists of one or more words that collectively
infer a meaning, such as a person’s address. Data refers to an atomic unit that
is stored in DBMS and is sometimes reassembled into information.

 

Examples
of data are a person’s street address, city, state, and zip code. Each of these
is an atomic unit that is commonly found in DBMS. A J2ME application can access
one or multiple atomic units as required by the application. Data is organized
in a database so that a J2ME application can quickly find, retrieve, update or
delete one or more data elements.

 

4.2
Databases

 

A
database in the purest sense is a collection of data. While we can use Java and
Java’s IO classes to create our own database, we shall probably interact with a
commercially available DBMS. DBMSs use proprietary and public domain algorithms
to assure fast and secure interaction with data stored in the database. Most
DBMS adhere to a widely accepted relation database model. A database model is a
description of how data is organized in a database .In a relation database
model, data is grouped into tables using a technique called normalization.

 

Once
a database and at least one table are created, a J2ME application can send SQL
statements to the DBMS to perform the followings.

  • Save data
  • Retrieve data
  • Update data
  • Manipulate data
  • Delete data

 

4.3
Tables

 

A
table is the component of database that contains data in the form of rows and
columns, very similar to a spreadsheet. A row contains related data such as
clients’ names and addresses. A column contains like data such as client’s
first names .Each column is identified by a unique name, called a column name
that describes the data contained in the column. For example, “client first
name” is a likely choice as the name of a column that contains clients’ first
names. In addition, columns are defined by attributes. An attribute describes
the characteristics of data that can be stored in the column. Attributes include
size, data type, and format.

 

Database
name, table name, column name, column attributes, and other information that
describe database components are known as metadata. Metadata is data about data
.For example, the size of client first name column describes the data contained
within the column and therefore is referred to as metadata. Metadata is used by
J2ME applications to identify components without needing to know details of a
column, table, or the database .For example, a J2ME application can request
from the DBMS the data type of a special column .The column type is used by a
J2ME application to copy data retrieved from the DBMS into a Java collection.

 

4.4
Client/Server Databases

 

Client/Server
databases are designed for use over networks, enabling multiple users to work
simultaneously with the same data. The database itself acts as server, not
unlike the Web servers. In principle it can field requests from just about
anywhere with a network connection and a suitable client program. That said, there’s
no reason why we can’t run both on the same machine.

 

Client/Server
databases are more closely analogous to the earlier metaphor of the public
lending library. It’s open to anyone who has a membership card and, with
several staff members on the reception desk, can deal with request from a
number of version at once. The visitors may be better in person, or may call in
on the telephone.

 

 

4.5
Data Types

 

A
data type describes the characteristics of data associated with a data element.
For example, a street address is likely to be an alphanumeric data type because
a street has a mixture of characters and numbers. 

  • Character, also
    referred to as text: Stores alphabetic characters and punctuation.
  • Alpha stores only
    alphabetical characters, punctuation, and numbers.
  • Alphanumeric stores
    alphabetical characters, punctuation, and numbers.
  • Numeric stores numbers
    only.
  • Data/Time stores dates
    and time values.
  • Logical (Boolean)
    stores one of two values: true or false, 0 or 1, or yes or no.
  • LOB (large object)
    stores large text fields, images, and other binary data.    

 

4.6
Normalization

 

 Normalization is defined as “the process of
breaking up the data into several tables, so as to minimize the number of times
we have to repeat the same data”. The normal forms are degrees of
normalization, and they are government by elegant set of rules.

  1. First normal form (1NF): First normal from requires that information is
    automatic.
  2. Second normal form (2NF): Second normal from requires data to be in the
    first normal from. In addition, data elements are organized into groups
    eliminating redundant data. Each group contains a primary key and non-key
    data must be functionality dependent on primary key.
  3. Third normal form (3NF): Third normal from requires that data elements be
    in the second normal form, and non-key data must not contain transitive
    dependencies.

 

4.7 Primary Keys

 

A primary key is a data element that uniquely
identifies a row of data elements within groups. The data selected to become
the primary key may or may not exist in the data list generated as the result
of analyzing entities. Sometimes a data element, such as an order number, is
used as the primary key.

 

4.8 Foreign Keys

 

A foreign key is a primary key of another group used
to draw a relationship between two groups of data elements. Relationships
between two groups are made using the value of foreign key and not necessarily
the name of a foreign key.

 

4.9 The Concepts of JDBC

 

Sun met the challenge in 1996 with the creation of the
JDBC driver and the JDBC API. Both were created out of necessary because until
then Java couldn’t access DBMSs and therefore wasn’t considered an
industrial-strength programming language. The JDBC driver developed
functionality of a JDBC driver.

                                               

JDBC drivers created by DBMS manufactures
have to:

  • Open a connection
    between the DBMS and the J2ME application.
  • Translate low-level
    equivalents of SQL statements sent by the J2ME application into message
    that can be processed by the DBMS
  • Return data that
    conforms to the JDBC specification to the JDBC driver.
  • Return information,
    such as error messages, that conforms to the JDBC specification to the
    JDBC driver.
  • Provide transaction
    management routines that conform to the JDBC specification.
  • Close the connection
    between the DBMS and the J2ME application.

 

 

4.9.1
Load the JDBC Driver

 

The
JDBC driver must be loaded before the J2ME application can connect to the DBMS.
The Class.forName() method is used to load the JDBC driver. Suppose a developer
wants to work offline and write a J2ME application that interacts with
Microsoft Access on the developer’s PC. The developer must write a routine that
loads the JDBC/ODBC Bridge driver called sun.jdbc.odbc.JdbcOdbcDriver. The
driver is loaded by calling the Class.forName() method and passing it the name
of the driver, as shown in the  following
code segment:

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

 

4.10
Connect to the DBMS

 

Once
the driver is loaded, the J2ME application must connect to the DBMS using the
DriverManager.getConnection() method. The java.sql.DriverManager class is the
highest class in the java.sql hierarchy and is responsible for managing driver
information. The DriverManager.getConnection() method is passed the URL of the
database, along with the user ID and password if required by the DBMS. The URL
is a String object that contains the driver name and the name of the database
that is being accessed by the J2ME application.

 

The
DriverManager.getConnection() returns Connection interface that is used
throughout the process of reference the database. The java.sql.Connection
interface is another number of the java.sql package that manages communications
between the driver and the J2ME application.It is the java.sql.Connection
interface that sends statements to the DBMS for processing.Following codes are
the use of the DriverMannager.getConnection method to load the JDBC/ODBC Bridge
and  connect to the CustomerInformation
database.

 

String
url = “jdbc:odbc:CustomerInformation”;

String
userID = “jim”;

String
password = “keogh”;

Statementr
DataRequest;

Private
Connection Db;

try{class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

Db
= DriverManager.getConnection(url,userID,password);

}

 

4.11
Create and Execute an SQL Statement

 

The
next step after the JDBC loaded and a connectio

n
is successfully made with a particular database by the DBMS is to send an SQL
query to the DBMS for processing .An SQL query consists of a series of SQL
commends that direct the DBMS to do something, such as return of data to the
J2ME application.

           

The
Connection.createStatement() is used to create a Statement object. The
Statement object then used to execute query and return a ResultSet object that
contains the response from the DBMS, which is usually one or more rows of
information requested by the J2ME application.Typically, the query is assigned
to a String object ,which is passed to the Statement object’s executeQuery()
method, as illustrated in the next code segment. Once the ResultSet is received
from the DBMS, the close() method is called to terminate the statement.
Following code retrieves all the rows and columns from the Customer table.

 

Statement
DataRequest;

ResultSet
Results;

try{

 string query = 
“SELECT * FROM Customers”;

DataRequest
= Database.createStatement();

DataRequest
= Db.createStatement();

Results
= DataRequest.executeQuery(query);

DataRequest.close();

Implementation

 

5.1 
Introduction

 

In Bangladesh, e-Voting System using mobile device is
not implemented. So we decided to work with this. E-Voting System using mobile
device means to vote though the mobile technology. In our thesis we had make
study on e-Voting System using mobile device.

 

5.2  System Architecture of Our e-Voting System

 

In our system we use a server (PC) to hold the
necessary database with a mobile connected to it as a bridge/gateway, and also
a client mobile for voting. To send vote the client mobile has to get connected
with the server mobile. The vote is send to the database server pc through the
server mobile. Then the server (PC) makes the decision according to the
message. By this system one can vote to a candidate using mobile device from
anywhere in Bangladesh, if there, mobile network is available. Any candidate
can vote who has a valid id checked by the database. The system architecture is
shown in the following picture.


 

 

 

 

 

 

 

 

 

 

 

Figure
5.1 System Architecture of the software

 

5.3    Flow Chart of Our e-Voting System

 

The working flowchart of our application is shown in
the following flowchart:

                                                Figure-5.2
Flowchart of our system

 

 

5.3 
Client Software

 

In
client software, at first voter have to login for voting. To do so he/she has
to submit votername, voterid, phonenumber correctly. After that, he/she has to
select store option, then he/she will get five options. They are describes as
below:

 

·        
LOGIN: It has
three options. These are votername, voterid, phonenumber. So a voter must fill
up the login form. If the voter do not insert votername, voterid, phonenumber
in the login form correctly, then he/she cannot get the permission to access
other options.

 

·        
FOR GIVING VOTE:
It has the voting candidates symbolic names in our application there are five
options. These are RED, WHITE, BLUE, GREEN and BLACK with corresponding symbol.
Star symbols represent the symbols for candidate. To vote a particular
candidate a voter has to choose one option from the list, voter can upload
his/her vote, else he/she can exit from the CandadateSelection form.

·        
TO GET
CONFIRMATION MESSAGE: To get confirm, a voter will enter his or her voterid.
After it he or she can download the confirmation message.

 

·        
TO KNOW VOTING
RESULT AT THIS TIME:  To know voting
result , a voter will enter his/her voterid. After it he/she can download the
candidates result.

 

·        
LOGOUT: A voter
can logout after completing all the process of the voting system.

 

5.4 
Server Software

 

In
the server software, there is a database name vote_db. This database has two
table. These are:

Voterinformationtable:It has six attributes. These are id, voterid,
postingDate, votername, phonenum and symbol.

 

Votertable: It has three attributes. These are votername,
voterid, phonenum.

 

So
at first, votername, voterid and voter phone number must be stored in the
votertable. Otherwise a voter will not be able to vote someone. So some
information about the voter stored in the votertable is denoted a valid voter.
A person whose information is not stored in the votertabe is not a valid voter.

 

On
the other hand, a last date for voting is given in this voting system. So after
this date, a voter will not be able to vote someone.

 

5.5 
Screen Shot of
This Software

5.6 
 

A
voter must fill up the voter login form by giving his/her name, voter id and
phonenumber.

 

 

Figure-5.3
Screen Shot-1

A
voter has ability to vote for three times. So a voter will get the following
information.

 

 

                                                Figure-5.4
Screen Shot-2

 

Wrong voter cannot login to vote someone.

 

           

                                                       

     Figure-5.5 Screen Shot-3

 

For
giving a vote, voter will see the following form and then a voter can select a
candidate’s symbol to vote someone.

 

                                                      

 Figure-5.6
Screen Shot-4

After
uploading the vote, voter will see the following message.

 

 

                                                Figure-5.7
Screen Shot-5

 

To
get confirmation message, voter will see the following information.

 

 

 

                                                Figure-5.8
Screen Shot-6

To
know the result, voter must give voterid to get the candidate result at this
moment.

 

 

 

                                                Figure-5.9
Screen Shot-7

 

 

 

Voter
will see the following information. Then voter must do logout.

 

 

                                                Figure-5.10
Screen Shot-8

 

After
voter logout voter will see the following message. When last voting date will
be over, then a voter will see the following message while voter try to login.

 

 

                                                            Figure-5.11 Screen Shot-9

 

 

 

Discussion

 

6.1 Advantage of our system

o  In our mobile based voting project, a candidate can
participate in election without going to vote centre that can save candidate’s
lot of time.

o  It will not only save candidate’s valuable time but
also eases the work of volunteers who are involved in the election centre. It
will help to fasten the overall voting system in a country.

o  A registered participant can only participates in
election by this software. This makes the process safe and secure.

o  It can be a alternate choice of internet by which
foreign citizen can participate in election.

o  The software is easy to use. The end users can use it
easily as they choose a candidate in ballot papers.

 

6.2 Limitations of our
system

 

o  A user must have a mobile to use the software. Only a
part of our population (more than 60%) using mobile.

o  As the user must registered before voting it is not
free for all citizen.

o  The user must send his/her choice to a particular cell
number. So network problem may delay the process.     

 

6.3 Scopes for
future

We
are interested to expand our project in future. To make our system web based is
our future planning where we will able to add a lot of information about a
candidate. Thus all citizens’ record can be taken under a database. Then a
candidate will be able to vote to a particular web address and network problem
will be solved and a website will be making up only for voting

 

 

6.4 Deploy

In our thesis we did not test our application in
practical life i.e. using a mobile set. We have observed our output using
simulator mobile screen. But it is possible to deploy our code using a mobile.
We can deploy the MIDlet directly on mobile device. In order to do this we need
a data cable connection between computer and handset.

 

6.5 Conclusion

The
field of wireless communication grows very rapidly. Our desire was to work in
this field. We have developed an e-voting system application under
client-server architecture. The connection is point-to point. Our developed
application was simulated and tested. We have further interest to work in this
field.

 

Appendix

This
Voting System software is made up of six packages.                 

 

In
VotingSystem\src\com\alessandrolacava\wirelessblog directory contains six
packages. These are connector, gui, login, midlet , model, util.

 

In
the conector package there are four class.

//loginSender.java

package
com.alessandrolacava.wirelessblog.connector;

import
java.io.IOException;

import
java.io.InputStream;

import
javax.microedition.io.Connector;

import
javax.microedition.io.HttpConnection;

import
javax.microedition.lcdui.Displayable;

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

public
class loginSender implements Runnable

 

            private String votername;

            private String password;

            private String phonenum;

            private String URL =
“http://localhost/Votephp/login_sender.php”;

            private VotingSystem midlet;

            private Displayable previousDisplay;

            private String result;

            public loginSender(VotingSystem
midlet, Displayable previousDisplay,

            String votername, String
password,String phonenum)

            this.midlet = midlet;

            this.previousDisplay =
previousDisplay;

            this.votername = votername;

            this.password = password;

            this.phonenum = phonenum;

            public void run()

            Try sendPost();

            catch (Exception e)

            e.printStackTrace();

            System.err.println(“ERROR:
” + e.toString());

            networkError(e.toString());

            public void start()

            Thread t = new Thread(this);

            Try t.start();

            catch (Exception e)

            System.err.println(“ERROR:
” + e.toString());

            networkError(e.toString());

 

            private void sendPost() throws
IOException

           

            InputStream is = null;

            StringBuffer sb = null;

            HttpConnection http = null;

            try

                       

            // append the query string onto the
URL

            URL += “?votername=” +
votername + “&password=” + password+ “&phonenum=” +
phonenum;

//
replace not allowed char in the URL

URL
= EncodeURL(URL);

//
establish the connection

http
= (HttpConnection) Connector.open(URL);

//
set the request method as GET

http.setRequestMethod(HttpConnection.GET);

//
server response

if
(http.getResponseCode() == HttpConnection.HTTP_OK)

                                   

            sb = new StringBuffer();

            int ch;

            is = http.openInputStream();

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

            sb.append((char) ch);

            else

            System.out.println(“NETWORK
ERROR”);

            networkError();

            catch (Exception e)

            System.err.println(“ERROR:
” + e.toString());

            networkError(e.toString());

                       

            finally

                       

            if (is != null)

                        is.close();

                        if (sb != null)

                        result = sb.toString();

                        else

                        networkError();

                                    if (http !=
null)

                                    http.close()
if (result != “”)

                       

                                    System.out.println(result);

                                    midlet.showInfo(result,
getCurrentDisplay());else

                       

                                    networkError();

           

 

           

 

            private Displayable
getCurrentDisplay()

           

                        // get the current
display

                        Displayable d =
midlet.getCurrentDisplay();

                        // if it is an Alert set
the next display as the previous one

                        if
(d.getClass().getName().equals(“javax.microedition.lcdui.Alert”))

                       

                                    d =
previousDisplay;

                       

                        return d;private String
EncodeURL(String URL)

           

                        URL = replace(URL, ‘à’,
“%E0”);

                        URL = replace(URL, ‘è’,
“%E8”);

                        URL = replace(URL, ‘é’,
“%E9”);

                        URL = replace(URL, ‘ì’,
“%EC”);

                        URL = replace(URL, ‘ò’,
“%F2”);

                        URL = replace(URL, ‘ù’,
“%F9”);

                        URL = replace(URL, ‘$’,
“%24”);

                        URL = replace(URL, ‘#’,
“%23”);

                        URL = replace(URL, ‘£’,
“%A3”);

                        URL = replace(URL, ‘@’,
“%40”);

                        URL = replace(URL, ‘\”,
“%27”);

                        URL = replace(URL, ‘ ‘,
“%20”);

 

                        return URL;

 

            private String replace(String
source, char oldChar, String dest)

           

                        String ret =
“”;

                        for (int i = 0; i <
source.length(); i++)

                       

                        if (source.charAt(i) !=
oldChar)

                        ret += source.charAt(i);

                        else

                        ret += dest;

                       

                        return ret;

           

 

            private void networkError()

           

            midlet.showInfo(“NETWORK ERROR,
TRY LATER.”, getCurrentDisplay());

           

            private void networkError(String
msg)

           

            midlet.showInfo(msg,
getCurrentDisplay());

 

//PostRetriever.java

 

package
com.alessandrolacava.wirelessblog.connector;

 

import
java.io.IOException;

import
java.io.InputStream;

 

import
javax.microedition.io.Connector;

import
javax.microedition.io.HttpConnection;

import
javax.microedition.lcdui.Displayable;

 

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

 

public
class PostRetriever implements Runnable

 

            private String votername;

            private String password;

            private String phonenum;

            private String voterid;

            private String URL =
“http://localhost/Votephp/post_retriever.php”;

            private VotingSystem midlet;

            private Displayable previousDisplay;

            private String post;

 

            public PostRetriever(VotingSystem
midlet, Displayable previousDisplay,

                                    String
votername, String password, String voterid,String phonenum)

           

                        this.votername =
votername;

                        this.password =
password;

                        this.phonenum
= phonenum;

                        this.voterid = voterid;

                        this.midlet = midlet;

                        this.previousDisplay =
previousDisplay;public void run()

           

                        try

                       

                                    getPost();

                       

                        catch (Exception e)

                       

                                    System.err.println(“ERROR:
” + e.toString());

                                    networkError(e.toString());

                       

           

 

            public void start()

           

                        Thread t = new
Thread(this);

                        try

                       

                                    t.start();

                       

                        catch (Exception e)

                       

                        System.err.println(“ERROR:
” + e.toString());

                                    networkError(e.toString());

                       

           

 

            private void getPost() throws
IOException

           

                        InputStream is = null;

                        StringBuffer sb = null;

                        HttpConnection http =
null;

                        try

                       

                                    // append
the credentials and the author’s username onto the URL

                                    URL +=
“?votername=” + votername + “&password=” + password +

                                                                         “&voterid=” +
voterid+”&phonenum=” + phonenum;

                                    // replace
not allowed char in the URL

                                    URL =
EncodeURL(URL);

                                    // establish
the connection

                                    http =
(HttpConnection) Connector.open(URL);

                                    // set the
request method as GET

                                    http.setRequestMethod(HttpConnection.GET);

                                    // server
response

                                    if
(http.getResponseCode() == HttpConnection.HTTP_OK)

                                    {

                                                sb
= new StringBuffer();

                                                int
ch;

                                                is
= http.openInputStream();

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

                                                            sb.append((char)
ch);

                                    }

                                    else

                                    {

                                                System.out.println(“NETWORK
ERROR”);

                                                networkError();

                                    }

                        }

                        catch (Exception e)

                        {

                                    System.err.println(“ERROR:
” + e.toString());

                                    networkError(e.toString());

                        }

                        finally

                        {

                                    if (is !=
null)

                                                is.close();

                                    if (sb !=
null)

                                                post
= sb.toString();

                                    else

                                                networkError();

                                    if (http !=
null)

                                                http.close();

                        }

 

                        if (post != null)

                        {

                                    System.out.println(post);

                                    midlet.showPosts(post,
getCurrentDisplay());

                        }

                        else

                        {

                                    networkError();

                        }

            }

 

            private Displayable
getCurrentDisplay()

            {

                        // get the current
display

                        Displayable d =
midlet.getCurrentDisplay();

                        // if it is an Alert set
the next display as the previous one

                        if
(d.getClass().getName().equals(“javax.microedition.lcdui.Alert”))

                        {

                                    d =
previousDisplay;

                        }

                        return d;

            }

 

            private String EncodeURL(String URL)

            {

                        URL = replace(URL, ‘à’,
“%E0”);

                        URL = replace(URL, ‘è’,
“%E8”);

                        URL = replace(URL, ‘é’,
“%E9”);

                        URL = replace(URL, ‘ì’,
“%EC”);

                        URL = replace(URL, ‘ò’,
“%F2”);

                        URL = replace(URL, ‘ù’,
“%F9”);

                        URL = replace(URL, ‘$’,
“%24”);

                        URL = replace(URL, ‘#’,
“%23”);

                        URL = replace(URL, ‘£’,
“%A3”);

                        URL = replace(URL, ‘@’,
“%40”);

                        URL = replace(URL, ‘\”,
“%27”);

                        URL = replace(URL, ‘ ‘,
“%20”);

 

                        return URL;

            }

 

            private String replace(String
source, char oldChar, String dest)

            {

                        String ret =
“”;

                        for (int i = 0; i <
source.length(); i++)

                        {

                                    if
(source.charAt(i) != oldChar)

                                                ret
+= source.charAt(i);

                                    else

                                                ret
+= dest;

                        }

                        return ret;

            }

 

            private void networkError(String
msg)

            {

                        midlet.showInfo(msg,
getCurrentDisplay());

            }

            private void networkError()

            {

                        midlet.showInfo(“NETWORK
ERROR, TRY LATER”, getCurrentDisplay());

           

 

 

  //PostSender.java       

 

package
com.alessandrolacava.wirelessblog.connector;

 

import
java.io.IOException;

import
java.io.InputStream;

 

import
javax.microedition.io.Connector;

import
javax.microedition.io.HttpConnection;

import
javax.microedition.lcdui.Displayable;

 

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

 

public
class PostSender implements Runnable

{

 

           

            private String symbol;

            private String votername;

            private String password;

            private String phonenum;

            private String URL =
“http://localhost/Votephp/post_sender.php”;

            private VotingSystem midlet;

            private Displayable previousDisplay;

            private String result;

           

            public PostSender(VotingSystem
midlet, Displayable previousDisplay,String votername,

                        String password, String
symbol,String phonenum)

            {

                        this.votername =
votername;

                        this.password =
password;

                        this.phonenum =
phonenum;

                        this.midlet = midlet;

                        this.previousDisplay =
previousDisplay;

                        this.symbol = symbol;

                       

            }

 

            public void run()

            {

                        try

                        {

                                    sendPost();

                        }

                        catch (Exception e)

                        {

                                    e.printStackTrace();

                                    System.err.println(“ERROR:
” + e.toString());

                                    networkError(e.toString());

                        }

            }

 

            public void start()

            {

                        Thread t = new
Thread(this);

                        try

                        {

                                    t.start();

                        }

                        catch (Exception e)

                        {

                                    System.err.println(“ERROR:
” + e.toString());

                                    networkError(e.toString());

                        }

            }

 

            private void sendPost() throws
IOException

            {

                        InputStream is = null;

                        StringBuffer sb = null;

                        HttpConnection http =
null;

                        try

                        {

                                    // append
the query string onto the URL

                                    URL +=
“?votername=” + votername + “&password=” + password
+”&symbol=” + symbol+”&phonenum=” + phonenum;

                                    // replace
not allowed char in the URL

                                    URL =
EncodeURL(URL);

                                    // establish
the connection

                                    http =
(HttpConnection) Connector.open(URL);

                                    // set the
request method as GET

                                    http.setRequestMethod(HttpConnection.GET);

                                    // server
response

                                    if
(http.getResponseCode() == HttpConnection.HTTP_OK)

                                    {

                                                sb
= new StringBuffer();

                                                int
ch;

                                                is
= http.openInputStream();

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

                                                            sb.append((char)
ch);

                                    }

                                    else

                                    {

                                                System.out.println(“NETWORK
ERROR”);

                                                networkError();

                                    }

                        }

                        catch (Exception e)

                        {

                                    System.err.println(“ERROR:
” + e.toString());

                                    networkError(e.toString());

                        }

                        finally

                        {

                                    if (is !=
null)

                                                is.close();

                                    if (sb !=
null)

                                                result
= sb.toString();

                                    else

                                                networkError();

                                    if (http !=
null)

                                                http.close();

                        }

 

                        if (result !=
“”)

                        {

                                    System.out.println(result);

                                    midlet.showInfo(result,
getCurrentDisplay());

                        }

                        else

                        {

                                    networkError();

                        }

 

            }

 

            private Displayable
getCurrentDisplay()

            {

                        // get the current
display

                        Displayable
d = midlet.getCurrentDisplay();

                        // if it is an Alert set
the next display as the previous one

                        if
(d.getClass().getName().equals(“javax.microedition.lcdui.Alert”))

                        {

                                    d =
previousDisplay;

                        }

                        return d;

            }

 

            private String EncodeURL(String URL)

            {

                        URL = replace(URL, ‘à’,
“%E0”);

                        URL = replace(URL, ‘è’,
“%E8”);

                        URL = replace(URL, ‘é’,
“%E9”);

                        URL = replace(URL, ‘ì’,
“%EC”);

                        URL = replace(URL, ‘ò’,
“%F2”);

                        URL = replace(URL, ‘ù’,
“%F9”);

                        URL = replace(URL, ‘$’,
“%24”);

                        URL = replace(URL, ‘#’,
“%23”);

                        URL = replace(URL, ‘£’,
“%A3”);

                        URL = replace(URL, ‘@’,
“%40”);

                        URL = replace(URL, ‘\”,
“%27”);

                        URL = replace(URL, ‘ ‘,
“%20”);

 

                        return URL;

            }

 

            private String replace(String
source, char oldChar, String dest)

            {

                        String ret =
“”;

                        for (int i = 0; i <
source.length(); i++)

                        {

                                    if
(source.charAt(i) != oldChar)

                                                ret
+= source.charAt(i);

                                    else

                                                ret
+= dest;

                        }

                        return ret;

            }

 

            private void networkError()

            {

                        midlet.showInfo(“NETWORK
ERROR , TRY LATER .”, getCurrentDisplay());

            }

            private void networkError(String
msg)

            {

                        midlet.showInfo(msg,
getCurrentDisplay());

            }

}

//ResultRetriever.java

package
com.alessandrolacava.wirelessblog.connector;

 

import
java.io.IOException;

import
java.io.InputStream;

 

import
javax.microedition.io.Connector;

import
javax.microedition.io.HttpConnection;

import
javax.microedition.lcdui.Displayable;

 

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

 

public
class ResultRetriever implements Runnable

{

            private String votername;

            private String password;

            private String phonenum;

            private String voterid;

            private String URL =
“http://localhost/Votephp/result_retriever.php”;

            private VotingSystem midlet;

            private Displayable previousDisplay;

            private String post;

 

            public ResultRetriever(VotingSystem
midlet, Displayable previousDisplay,

                                    String
votername, String password, String voterid,String phonenum)

            {

                        this.votername =
votername;

                        this.password =
password;

                        this.voterid = voterid;

                        this.phonenum =
phonenum;

                        this.midlet
= midlet;

                        this.previousDisplay =
previousDisplay;

            }

 

            public void run()

            {

                        try

                        {

                                    getPost();

                        }

                        catch (Exception e)

                        {

                                    System.err.println(“ERROR:
” + e.toString());

                                    networkError(e.toString());

                        }

            }

 

            public void start()

            {

                        Thread t = new
Thread(this);

                        try

                        {

                                    t.start();

                        }

                        catch (Exception e)

                        {

                                    System.err.println(“ERROR:
” + e.toString());

                                    networkError(e.toString());

                        }

            }

 

            private void getPost() throws
IOException

            {

                        InputStream is = null;

                        StringBuffer sb = null;

                        HttpConnection http =
null;

                        try

                        {

                                    // append
the credentials and the author’s username onto the URL

                                    URL +=
“?votername=” + votername + “&password=” + password +

                                                                         “&voterid=” +
voterid+”&phonenum=” + phonenum;

                                    // replace not
allowed char in the URL

                                    URL =
EncodeURL(URL);

                                    // establish
the connection

                                    http =
(HttpConnection) Connector.open(URL);

                                    // set the
request method as GET

                                    http.setRequestMethod(HttpConnection.GET);

                                    // server
response

                                    if
(http.getResponseCode() == HttpConnection.HTTP_OK)

                                    {

                                                sb
= new StringBuffer();

                                                int
ch;

                                                is
= http.openInputStream();

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

                                                            sb.append((char)
ch);

                                    }

                                    else

                                    {

                                                System.out.println(“NETWORK
ERROR”);

                                                networkError();

                                    }

                        }

                        catch (Exception e)

                        {

                                    System.err.println(“ERROR:
” + e.toString());

                                    networkError(e.toString());

                        }

                        finally

                        {

                                    if (is !=
null)

                                                is.close();

                                    if (sb !=
null)

                                                post
= sb.toString();

                                    else

                                                networkError();

                                    if (http != null)

                                                http.close();

                        }

 

                        if (post != null)

                        {

                                    System.out.println(post);

                                    midlet.showPosts(post,
getCurrentDisplay());

                        }

                        else

                        {

                                    networkError();

                        }

            }

 

            private Displayable
getCurrentDisplay()

            {

                        // get the current
display

                        Displayable d =
midlet.getCurrentDisplay();

                        // if it is an Alert set
the next display as the previous one

                        if
(d.getClass().getName().equals(“javax.microedition.lcdui.Alert”))

                        {

                                    d =
previousDisplay;

                        }

                        return d;

            }

 

            private String EncodeURL(String URL)

            {

                        URL = replace(URL, ‘à’,
“%E0”);

                        URL = replace(URL, ‘è’,
“%E8”);

                        URL = replace(URL, ‘é’,
“%E9”);

                        URL = replace(URL, ‘ì’,
“%EC”);

                        URL = replace(URL, ‘ò’,
“%F2”);

                        URL = replace(URL, ‘ù’,
“%F9”);

                        URL = replace(URL, ‘$’,
“%24”);

                        URL = replace(URL, ‘#’,
“%23”);

                        URL = replace(URL, ‘£’,
“%A3”);

                        URL = replace(URL, ‘@’,
“%40”);

                        URL = replace(URL, ‘\”,
“%27”);

                        URL = replace(URL, ‘ ‘,
“%20”);

 

                        return URL;

            }

 

            private String replace(String
source, char oldChar, String dest)

            {

                        String ret =
“”;

                        for (int i = 0; i <
source.length(); i++)

                        {

                                    if
(source.charAt(i) != oldChar)

                                                ret
+= source.charAt(i);

                                    else

                                                ret
+= dest;

                        }

                        return ret;

            }

 

            private void networkError(String
msg)

           

                        midlet.showInfo(msg,
getCurrentDisplay());

           

            private void networkError()

           

            midlet.showInfo(“NETWORK ERROR
, TRY LATER .”, getCurrentDisplay());

 

In
gui package has six classes

//FormDisplayPost.java

package
com.alessandrolacava.wirelessblog.gui;

 

import
javax.microedition.lcdui.Command;

import
javax.microedition.lcdui.Displayable;

import
javax.microedition.lcdui.Form;

import
javax.microedition.lcdui.CommandListener;

import
javax.microedition.lcdui.StringItem;

 

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

import
com.alessandrolacava.wirelessblog.model.Post;

import
com.alessandrolacava.wirelessblog.util.CommandBuilder;

 

public
class FormDisplayPost extends Form implements CommandListener

{

            //midlet

            private VotingSystem midlet;

            //previous display

            private Displayable previousDisplay;

           

            //items

            private StringItem siVotername;

            private StringItem siSymbol;

            private StringItem siPostingDate;

           

            //commands

            private static final Command cmExit
= CommandBuilder.getExit();

            private static final Command cmMain
= CommandBuilder.getMain();

            private static final Command cmBack
= CommandBuilder.getBack();

 

            public FormDisplayPost(VotingSystem
midlet, Displayable previousDisplay,

                                    Post post)

            {

                        //call the Form
constructor

                        super(“VOTED BY
” + post.getvoterid());

                       

                        this.midlet = midlet;

                        this.previousDisplay =
previousDisplay;

                       

                        //items

                        siVotername = new
StringItem(“VOTER NAME: “, post.getTitle());

                        siSymbol = new
StringItem(“VOTE IS GIVEN TO: “, post.getText());

                        siPostingDate = new
StringItem(“VOTING DATE: “, post.getPostingDate());

                       

                       

                        //append the items to
the form

                        append(siVotername);

                        append(siSymbol);

                        append(siPostingDate);

                       

                        //add the commands to
the form

                        addCommand(cmExit);

                        addCommand(cmMain);

                        addCommand(cmBack);

                       

                        //set the command
listener

                        setCommandListener(this);     

            }

 

            //called when a command is selected

            public void commandAction(Command c,
Displayable d)

            {

                        if(c == cmExit) //exit
the app

                        {

                                    midlet.shutDownApp(false);

                        }

                        else if(c == cmBack) //
back to the previous Display

                        {

                                    midlet.setDisplay(previousDisplay);

                        }

                        else if(c == cmMain)
//back to the main menu

                        {

                                    midlet.setDisplay(midlet.getMain());

                       

//FormDownloadPost.java

package
com.alessandrolacava.wirelessblog.gui;

 

import
javax.microedition.lcdui.Command;

import
javax.microedition.lcdui.CommandListener;

import
javax.microedition.lcdui.Displayable;

import
javax.microedition.lcdui.Form;

import
javax.microedition.lcdui.TextField;

 

import
com.alessandrolacava.wirelessblog.connector.PostRetriever;

import
com.alessandrolacava.wirelessblog.login.Login;

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

import
com.alessandrolacava.wirelessblog.util.CommandBuilder;

 

public
class FormDownloadPost extends Form implements CommandListener

{

            //midlet

            private VotingSystem midlet;

            //previous display

            private Displayable previousDisplay;

           

            //items

            private TextField tfFrompass;

           

            //commands

            private static final Command cmExit
= CommandBuilder.getExit();

            private static final Command
cmDownload = CommandBuilder.getDownload();

            private static final Command cmBack
= CommandBuilder.getBack();

 

            public FormDownloadPost(VotingSystem
midlet, Displayable previousDisplay)

            {

                        //call the Form
constructor passing the title

                        super(“DOWNLOAD
CONFIRMATION MESSAGE”);

                       

                        this.midlet = midlet;

                        this.previousDisplay =
previousDisplay;

                       

                        tfFrompass = new
TextField(“ENTER VOTERID”, “”, 20, TextField.PASSWORD);

                       

                        //append the items to
the form

                        append(tfFrompass);

                       

                        //add the commands to
the form

                        addCommand(cmExit);

                        addCommand(cmDownload);

                        addCommand(cmBack);

                       

                        //set the command
listener

                        setCommandListener(this);     

           

 

            //called when a command is selected

            public void commandAction(Command c,
Displayable d)

           

                        if(c == cmExit)

                       

                                    midlet.shutDownApp(false);

                       

                        else if(c == cmBack)

                       

                                    midlet.setDisplay(previousDisplay);

                       

                        else if(c == cmDownload)

                       

                                    //retrieve
login data

                                    Login login
= new Login();

                                    //username

                                    String
votername = login.getUsername();

                                    //password

                                    String
password = login.getPassword();

                                    String
phonenum = login.getPhonenum();

                                    //author

                                    //TODO:
CHECK THE VALIDITY OF THE VOTERID //STRING

                                    String
voterid = tfFrompass.getString();

                                    //retrieve
the post

                                    PostRetriever
pr = new PostRetriever(midlet, this,

                                    votername,
password, voterid,phonenum);

                                    pr.start();

 

//FormLogin.java

package
com.alessandrolacava.wirelessblog.gui;

import
javax.microedition.lcdui.*;

import
com.alessandrolacava.wirelessblog.connector.loginSender;

import
com.alessandrolacava.wirelessblog.login.Login;

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

import
com.alessandrolacava.wirelessblog.util.CommandBuilder;

import
com.alessandrolacava.wirelessblog.util.RecordManager;

 

public
class FormLogin extends Form implements CommandListener

 

            // items

            private TextField tfvotername;

            private TextField tfPassword;

            private TextField tfPhonenum;

           

            // RS name

            private final String RS =
“LOGIN”;

           

            // midlet

            private VotingSystem midlet;

           

            //previous display

            private Displayable previousDisplay;

           

            // commands

            private static final Command
cmStoreLogin = CommandBuilder.getStoreLogin();

            private static final Command cmBack
= CommandBuilder.getBack();

            //private static final Command
cmMain = CommandBuilder.getMain();

            private static final Command cmExit
= CommandBuilder.getExit();   

           

            // login manager

            private Login login;

           

            public FormLogin(VotingSystem
midlet, Displayable previousDisplay)

           

                        super(“ENTER YOUR
NAME & VOTERID FOR LOGIN”);

                        //midlet

                        this.midlet = midlet;

                        //previous display

                        this.previousDisplay =
previousDisplay;

                       

                        //text fields

                        tfvotername = new
TextField(“VOTER NAME”, “”, 20, TextField.ANY);

                        tfPassword = new
TextField(“VOTER ID”, “”, 20, TextField.PASSWORD);

                        tfPhonenum = new
TextField(“VOTER PHONE NUMBER”, “”, 20,

 

TextField.PASSWORD);

                       

                        //add the items to the
form

                        append(tfvotername);

                        append(tfPassword);

                        append(tfPhonenum);

                       

                        //add the commands

                        addCommand(cmStoreLogin);

                        addCommand(cmExit);

                        addCommand(cmBack);

                        //addCommand(cmMain);

           

                        //command listener

                        setCommandListener(this);

                       

                        // login manager

                        login = new Login();

                       

           

           

            //clear the fields

            public void clearFields()

           

                        tfPassword.setString(“”);                     

                        tfvotername.setString(“”);

                        tfPhonenum
.setString(“”);

           

            public void commandAction(Command c,
Displayable d)

           

                        RecordManager rm = new
RecordManager(RS);

                        int numRecords =
rm.numRecords();

                        if(c == cmExit) //exit
the app

                                    midlet.shutDownApp(false);

                        //Note: the back and
main commands can be invoked only if there is already a login info

                        if(c == cmBack)
//previous display

                                    if(numRecords
< 3)

                                                notValidData();

                        else

                                                midlet.setDisplay(previousDisplay);

                                   

                        else
if(c == cmStoreLogin) //store the new login info

                                    String
votername = tfvotername.getString().trim();

                                    String
password = tfPassword.getString().trim();

                                    String
phonenum = tfPhonenum.getString().trim();

                                    //check the
validity of the fields

                                    if(votername.equals(“”)
|| password.equals(“”)|| phonenum.equals(“”))

                                                //not
valid

                                                notValidData();

                                    else

                                                //store
the new login info

                                                login.setUsername(votername);

                                                login.setPassword(password);

                                                login.setPhonenum(phonenum);

                                                loginSender
pr = new loginSender(midlet, this,

                                                            votername,
password,phonenum);

                                                            pr.start();

                                                           

                                                //get
back to the previous display

                                                //midlet.setDisplay(previousDisplay);

           

            private void notValidData()

           

                        Alert alert = new
Alert(“ERROR”, “TOU MUST SUPPLY USERNAME ,PASSWORD AND PHONE
NUMBER, TRY AGAIN .”, null, AlertType.INFO);

                        alert.setTimeout(Alert.FOREVER);

                        midlet.setDisplay(alert,
this);

                       

//FormLogout.java

package
com.alessandrolacava.wirelessblog.gui;

 

import
javax.microedition.lcdui.*;

 

 

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

import
com.alessandrolacava.wirelessblog.util.CommandBuilder;

 

public
class FormLogout extends Form implements CommandListener

           

            private final String RS =
“LOGIN”;

           

            // midlet

            private VotingSystem midlet;

           

           

            private Displayable previousDisplay;

           

            private static final Command cmExit
= CommandBuilder.getExit();   

           

           

           

            public FormLogout(VotingSystem
midlet, Displayable previousDisplay)

                        super(“IT IS JUST
LOGOUT FORM”);

                        //midlet

                        this.midlet = midlet;

                        //previous display

                        this.previousDisplay =
previousDisplay;

                       

                        append(new
StringItem(“\n\n\nYOU ARE IN LOGOUT FORM NOW”,”\n\n\nTHANKS FOR
YOUR LOGOUT.”));

                        addCommand(cmExit);

                        //command listener

                        setCommandListener(this);

           

            public void commandAction(Command c,
Displayable d)

                        if(c == cmExit) //exit
the app

                       

                                    midlet.shutDownApp(false);

           

//FormResultDownLoad.java

package
com.alessandrolacava.wirelessblog.gui;

 

import
javax.microedition.lcdui.Command;

import
javax.microedition.lcdui.CommandListener;

import
javax.microedition.lcdui.Displayable;

import
javax.microedition.lcdui.Form;

import
javax.microedition.lcdui.TextField;

 

import
com.alessandrolacava.wirelessblog.connector.ResultRetriever;

import
com.alessandrolacava.wirelessblog.login.Login;

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

import
com.alessandrolacava.wirelessblog.util.CommandBuilder;

 

public
class FormResultDownLoad extends Form implements CommandListener

            //midlet

            private VotingSystem midlet;

            //previous display

            private Displayable previousDisplay;

           

            //items

            private TextField tfFrompass;

           

            //commands

            private static final Command cmExit
= CommandBuilder.getExit();

            private static final Command
cmDownload = CommandBuilder.getDownload();

            private static final Command cmBack
= CommandBuilder.getBack();

 

            public
FormResultDownLoad(VotingSystem midlet, Displayable previousDisplay)

           

                        //call the Form
constructor passing the VOTERNAME

                        super(“DOWNLOAD THE
VOTING RESULT”);

                       

                        this.midlet = midlet;

                        this.previousDisplay =
previousDisplay;

                       

                        tfFrompass = new
TextField(“ENTER THE VOTERID”, “”, 20, TextField.PASSWORD);

                       

                        //append the items to
the form

                        append(tfFrompass);

                       

                        //add the commands to
the form

                        addCommand(cmExit);

                        addCommand(cmDownload);

                        addCommand(cmBack);

                       

                        //set the command
listener

                        setCommandListener(this);     

 

            //called when a command is selected

            public void commandAction(Command c,
Displayable d)

                        if(c == cmExit)

                        {

                                    midlet.shutDownApp(false);

                        }

                        else if(c == cmBack)

                        {

                                    midlet.setDisplay(previousDisplay);

                        }

                        else if(c == cmDownload)

                        {

                                    //retrieve
login data

                                    Login login
= new Login();

                                    //username

                                    String
votername = login.getUsername();

                                    //password

                                    String
password = login.getPassword();

                                    String
phonenum = login.getPhonenum();

                                    //author

                                    //TODO:
CHECK THE VALIDITY OF THE AUTHOR //STRING

                                    String
voterid = tfFrompass.getString();

                                    //retrieve
the post

                                     ResultRetriever rr = new
ResultRetriever(midlet, this,

                                                            votername,
password, voterid,phonenum);

                                    rr.start();

 

//FormWritePost.java

package
com.alessandrolacava.wirelessblog.gui;

 

import
javax.microedition.lcdui.*;

 

import
javax.microedition.lcdui.Command;

import
javax.microedition.lcdui.CommandListener;

import
javax.microedition.lcdui.Displayable;

import
javax.microedition.lcdui.Form;

import
javax.microedition.lcdui.TextField;

 

import
com.alessandrolacava.wirelessblog.connector.PostSender;

import
com.alessandrolacava.wirelessblog.login.Login;

import
com.alessandrolacava.wirelessblog.midlet.VotingSystem;

import
com.alessandrolacava.wirelessblog.util.CommandBuilder;

 

public
class FormWritePost extends Form implements CommandListener,ItemStateListener

            //midlet

            private VotingSystem midlet;

            //previous display

            private Displayable previousDisplay;

           

            //items

            private Image image;

            private ImageItem imageItem;

            private int defaultIndex;

            private ChoiceGroup radioButtons =
new ChoiceGroup(“SELECT A VOTING SYMBOL”, Choice.EXCLUSIVE);

                       

            //commands

            private static final Command cmExit
= CommandBuilder.getExit();

            private static final Command
cmUpload = CommandBuilder.getUpload();

            private static final Command cmBack
= CommandBuilder.getBack();

 

            public FormWritePost(VotingSystem
midlet, Displayable previousDisplay)

            {

                        //call the Form
constructor passing the title

                        super(“CANDIDATE
SELECTION”);

                        this.midlet = midlet;

                        this.previousDisplay =
previousDisplay;

                        radioButtons.append(“RED”,null);

                        radioButtons.append(“WHITE”,null);

                        radioButtons.append(“BLUE”,
null);

                    radioButtons.append(“GREEN”,
null);

                        radioButtons.append(“BLACK”,null);

             
try{

                        Image
image=Image.createImage(“/st-off.png”);

                        imageItem = new ImageItem(null,image,ImageItem.LAYOUT_CENTER,”My
image”);

                        radioButtons.set(0,”RED”,image);

                        radioButtons.set(1,”WHITE”,image);

                        radioButtons.set(2,”BLUE”,image);

                        radioButtons.set(3,”GREEN”,image);

                        radioButtons.set(4,”BLACK”,image);

                        catch(Exception e){}

                       

                       

                       

                        defaultIndex
= radioButtons.append(“NONE”, null);

                        radioButtons.setSelectedIndex(defaultIndex,
true);

                                   

                        append(radioButtons);

                        append(imageItem);

 

                        ////add the commands to
the form

                        addCommand(cmExit);

                        addCommand(cmUpload);

                        addCommand(cmBack);

                       

                        //set the command
listener

                        setCommandListener(this);

                        setItemStateListener(this);       

 

            //called when a command is selected

            public void commandAction(Command c,
Displayable d)

            {

                        if(c == cmExit)

                        {

                                    midlet.shutDownApp(false);

                        }

                        else if(c == cmBack)

                        {

                                    midlet.setDisplay(previousDisplay);

                        }

                        else if(c == cmUpload)

                        {

                                   

                                    upLoad();

           

 public void itemStateChanged(Item item) {

    if (item == radioButtons) {

      StringItem msg = new StringItem(“YOU
SELECTED “, radioButtons.getString(radioButtons

          .getSelectedIndex()));

      append(msg);

//
detect the menu item selected

public
void upLoad(){

 

                                    //retrieve
login data

                                    Login login
= new Login();

                                    //username

                                    String
votername = login.getUsername();

                                    //password

                                    String
password = login.getPassword();

                                    String
symbol; 

                                    String
phonenum = login.getPhonenum();                   

                                    int
menuIndex = radioButtons.getSelectedIndex();

                                   

                                    switch(menuIndex)

                                   

                                                case
0:

                                               

                                                           

                                                            symbol=”RED”;

                                                            PostSender
pr = new PostSender(midlet, this,

                                                            votername,
password, symbol,phonenum);

                                                            pr.start();

                                                            break;

                                                           

                                                case
1:

           

                                                            symbol=”WHITE”;

                                                            PostSender
pr = new PostSender(midlet, this,

                                                            votername,
password, symbol,phonenum);

                                                            pr.start();

                                                            break;

                                               

                                                case
2:

                                                            symbol=”BLUE”;

                                                            PostSender
pr = new PostSender(midlet, this,

                                                            votername,
password, symbol,phonenum);

                                                            pr.start();

                                                            break;

                                   

                                                case
3:

                                   

                                                            symbol=”GREEN”;

                                                            PostSender
pr = new PostSender(midlet, this,

                                                            votername,
password, symbol,phonenum);

                                                            pr.start();

                                                            break;

                                   

                                                case
4:

                                               

                                                            symbol=”BLACK”;     

                                                            PostSender
pr = new PostSender(midlet, this,

                                                            votername,
password, symbol,phonenum);

                                                            pr.start();         

                                                            break;

                                   

                                                case
5:

                                   

                                                            System.out.println(“LOGOUT”);

Alert
alert = new Alert(“INFORMATION”, “YOU HAVE SELECTED NONE OPTION
.\n YOU SHOULD TO SELECT ABOVE OPTIONS FOR VOTING”, null, AlertType.INFO);

                                                            alert.setTimeout(Alert.FOREVER);

                                                            midlet.setDisplay(alert,
this);

                                                            break;

 

In
login package has one class

//Login.java

package
com.alessandrolacava.wirelessblog.login;

import
com.alessandrolacava.wirelessblog.util.RecordManager;

 

//
the votername is stored at record 1

//
the password is stored at record 2

public
class Login

{

            private final String RS =
“LOGIN”;

            private RecordManager rm;

           

            public Login()

            {

                        rm = new
RecordManager(RS);

            }

           

            public String getUsername()

            {

                        return rm.getRecord(1);

            }

           

            public String getPassword()

            {

                        return rm.getRecord(2);

            }

            public String getPhonenum()

            {

                        return rm.getRecord(3);

            }

            public void setUsername(String
votername)

            {

                        if(rm.numRecords() == 0)

                        { //rm empty so add the
record

                                    rm.addRecord(votername);

                        }

                        else

                        {

                                    //rm not empty,
overwrite the record

                                    rm.setRecord(1,
votername);

                        }

            }

           

            public void setPassword(String
password)

            {

                        if(rm.numRecords() == 1)

                        { //rm empty so add the
record

                                    rm.addRecord(password);

                        }

                        else

                        {

                                    //rm not
empty, overwrite the record

                                    rm.setRecord(2, password);

                        }

            }

            public void setPhonenum(String
phonenum)

            {

                        if(rm.numRecords() == 2)

                        { //rm empty so add the
record

                                    rm.addRecord(phonenum);

                        }

                        else

                        {

                                    //rm not
empty, overwrite the record

                                    rm.setRecord(3,
phonenum);

                        }

            }

}

 

In
midlet package has one class

//VotingSystem.java

package
com.alessandrolacava.wirelessblog.midlet;

 

import
javax.microedition.lcdui.Alert;

import
javax.microedition.lcdui.AlertType;

import
javax.microedition.lcdui.Command;

import
javax.microedition.lcdui.CommandListener;

import
javax.microedition.lcdui.Display;

import
javax.microedition.lcdui.Displayable;

import
javax.microedition.lcdui.List;

import
javax.microedition.midlet.MIDlet;

 

import
com.alessandrolacava.wirelessblog.gui.FormResultDownLoad;

import
com.alessandrolacava.wirelessblog.gui.FormLogout;

import
com.alessandrolacava.wirelessblog.gui.FormDisplayPost;

import
com.alessandrolacava.wirelessblog.gui.FormDownloadPost;

import
com.alessandrolacava.wirelessblog.gui.FormLogin;

import
com.alessandrolacava.wirelessblog.gui.FormWritePost;

import
com.alessandrolacava.wirelessblog.model.Post;

import
com.alessandrolacava.wirelessblog.util.CommandBuilder;

import
com.alessandrolacava.wirelessblog.util.PostParser;

import
com.alessandrolacava.wirelessblog.util.RecordManager;

 

public
class VotingSystem extends MIDlet implements CommandListener

{

            // menu items

            private static final String[]
MENU_ITEMS = {“LOGIN”, “FOR GIVING VOTE”,

                                                                                    “TO
GET CONFIRMATION MESSAGE”,”TO KNOW VOTING RESULT AT THIS
TIME”,”LOGOUT”,};

            // display

            private Display display;

           

            // list representing the main menu

            private List lsMain;

            //commands for the main menu

            private Command cmExit =
CommandBuilder.getExit();

            private Command cmSelect =
CommandBuilder.getSelect();

            // form representing the login

            private FormLogin fmLogin;

            private FormLogout fmLogout;

            // write post form

            private FormWritePost fmWritePost;

            // download post form

            private FormDownloadPost
fmDownloadPost;

            //download result form

            private FormResultDownLoad fmResultLoadPost;

 

            public VotingSystem()

            {

                        super();

                       

                        // main menu list

                        lsMain = new
List(“Hlog”, List.EXCLUSIVE, MENU_ITEMS,null);

                        //add the commands to
the main menu

                        lsMain.addCommand(cmExit);

                        lsMain.addCommand(cmSelect);

                        //set the command listener

                        lsMain.setCommandListener(this);

                       

                        // the other displayable
elements:

                        // login form

                        fmLogin = new
FormLogin(this, lsMain);

                        fmLogout = new
FormLogout(this, lsMain);

                        // write post form

                        fmWritePost = new
FormWritePost(this, lsMain);

                        // write post form

                        fmDownloadPost = new
FormDownloadPost(this, lsMain);

                        //resultdownload form

                        fmResultLoadPost = new
FormResultDownLoad(this, lsMain);

                        //the display

                        display =
Display.getDisplay(this);

                       

            protected void startApp()

            {

                        // check if there is the
login info already stored

                        if (isLoginEmpty())

                        {

                                    setDisplay(fmLogin);

                        }

                        else

                        {

                                    setDisplay(lsMain);

                        }

            }

 

            protected void pauseApp()

            {}

 

            protected void destroyApp(boolean
unconditional)

            {

                        lsMain = null;

                        fmLogin = null;

                        display = null;

            }

           

            public void shutDownApp(boolean
unconditional)

            {

                        destroyApp(unconditional);

                        notifyDestroyed();

            }

           

            public void setDisplay(Displayable
d)

            {

                        display.setCurrent(d);

            }

 

            public void setDisplay(Alert a,
Displayable d)

            {

                        display.setCurrent(a,
d);

            }

           

            public Displayable getMain()

            {

                        return lsMain;

            }

           

            private boolean isLoginEmpty()

            {

                        RecordManager rm = new
RecordManager(“LOGIN”);

                        return (rm.numRecords()
< 3);

            }

 

            public void commandAction(Command c,
Displayable d)

            {

                        if(c == cmExit)

                        {

                                    shutDownApp(false);

                        }

                        else if(c == cmSelect)

                        {

                                    // detect
the menu item selected

                                    int
menuIndex = lsMain.getSelectedIndex();

                                    RecordManager
rm = new RecordManager(“LOGIN”);

                                    switch(menuIndex)

                                    {

                                                case
0: // logoin

                                                {

                                                            System.out.println(“LOGIN”);

                                                            //
delete the login data

                                                            //RecordManager
rm = new RecordManager(“LOGIN”);

                                                            rm.deleteRS();

                                                            //clear
the fields of the login form

                                                            fmLogin.clearFields();

                                                            //set
fmLogin as the current display

                                                            setDisplay(fmLogin);

                                                            break;

                                                }

                                                case
1: // write post

                                                {

                                                            System.out.println(“VOTE
FOR ELECTION”);

                                                            setDisplay(fmWritePost);

                                                            break;

                                                }

                                                case
2: // download post

                                                {

                                                            System.out.println(“DOWNLOAD
YOUR CONFIRM MSG”);

                                                            setDisplay(fmDownloadPost);

                                                            break;

                                                }

                                               

                                               

                                                case
3: // download result

                                                {

                                                            System.out.println(“DOWNLOAD
THE RESULT”);

                                                            setDisplay(fmResultLoadPost);

                                                            break;

                                                }

                                                case
4: // logout

                                                {

                                                            System.out.println(“LOGOUT”);

                                                            rm.deleteRS();

                                                            //clear
the fields of the login form

                                                            fmLogin.clearFields();

                                                            //set
fmLogin as the current display

                                                            setDisplay(fmLogout);

                                                            break;

                                   

           

            // show the post downloaded

            public void showPosts(String rawPost,
Displayable d)

            {

                       

                        PostParser pp = new
PostParser(rawPost);

                        try

                        {

                                    //extract
the Post from the rawPost

                                    Post post =
pp.parse();

                                    //fill the
form FormDisplayPost with the info extracted

                                    FormDisplayPost
fdp = new FormDisplayPost(this, d, post);

                                    //display it

                                    setDisplay(fdp);

                        }

                        catch(IllegalArgumentException
iae)

                        {

                                    System.out.println(iae.getMessage());

                                    //display
alert

                                    showInfo(iae.getMessage(),
d);

                        }

                        catch(IllegalStateException
ise)

                        {

                                    System.out.println(ise.getMessage());

                                    //display
alert

                                    showInfo(ise.getMessage(),
d);

                        }

                        catch(Exception e)

                        {

                                    e.printStackTrace();

                                    //display
alert

                                    showInfo(e.getMessage(),
d);

           

           

            // show the info passed in

            public void showInfo(String info,
Displayable d)

            {

                        //
create an alert

                        Alert alert = new
Alert(“INFORMATION”, info, null, AlertType.INFO);

                        // modal alert

                        alert.setTimeout(Alert.FOREVER);

                        // show the alert

                        setDisplay(alert, d);

            }

           

            // return the current display

            public Displayable getCurrentDisplay()

            {

                        return
display.getCurrent();

           

In
model package has one class

//Post.java

package
com.alessandrolacava.wirelessblog.model;

public
class Post

            private String voterid;

            private String postingDate;

            private String votername;

            private String symbol;

 

            public Post(String voterid, String
postingDate,

                                    String
votername, String symbol)

           

                        this.voterid = voterid;

                        this.postingDate =
postingDate;

                        this.votername =
votername;

                        this.symbol = symbol;

            }

           

            public Post()

            {}

           

            public String getvoterid()

            {

                        return voterid;

            }

            public void setvoterid(String
voterid)

            {

                        this.voterid = voterid;

            }

            public String getPostingDate()

            {

                        return postingDate;

            }

 

            public void setPostingDate(String
postingDate)

            {

                        this.postingDate =
postingDate;

            }

            public String getText()

            {

                        return symbol;

            }

            public void setText(String symbol)

            {

                        this.symbol = symbol;

            }

            public String getTitle()

            {

                        return votername;

            }

            public void setTitle(String
votername)

            {

                        this.votername =
votername;

            }

           

            public String toString()

            {

                        return “VOTER ID:
” + voterid +

                                                             ” DATE: ” + postingDate +

                                                             ” vOTER NAME: ” + votername +

                                                             ” GIVEN VOTE TO ” + symbol;

In
util package has four class

//CommandBuilder.java

package
com.alessandrolacava.wirelessblog.util;

import
javax.microedition.lcdui.Command;

 

public
class CommandBuilder

{

            public static Command getSelect()

            {

                        return new
Command(“Select”, Command.OK, 1);

            }

 

            public static Command getExit()

            {

                        return new
Command(“Exit”, Command.EXIT, 1);

            }

 

            public static Command getBack()

            {

                        return new
Command(“Back”, Command.BACK, 1);

            }

 

            public static Command getMain()

            {

                        return new
Command(“Main”, Command.ITEM, 1);

            }

 

            public static Command getDownload()

            {

                        return new
Command(“Download”, Command.ITEM, 1);

            }

 

            public static Command getUpload()

            {

                        return new
Command(“Upload”, Command.ITEM, 1);

            }

 

            public static Command
getStoreLogin()

            {

                        return new
Command(“Store”, Command.ITEM, 1);

           

//PostParser.java

package
com.alessandrolacava.wirelessblog.util;

 

import
java.util.Vector;

 

import
com.alessandrolacava.wirelessblog.model.Post;

 

public
class PostParser

{

            //String used to separate the items

            private static final String SPLITTER
= “|”;

           

            //post in the raw format which is:
author|date|title|text

  private String rawPost = “”;

  //index pointer used by the parser

  private int index;

 

  public PostParser(String rawPost)

  {

            this.rawPost
= rawPost;

            this.index
= 0;

  }

           

            public Post parse()

           

                        //check if the argument
is valid

                        if(rawPost.length() ==
0)

                        {

                                    throw new
IllegalArgumentException(“Empty String passed”);

                        }

                        //extract the 4 items of
the post

                        String[] items =
extractItems();

                        //if the items are != 4
then an exception is thrown

                        if(items.length == 1)

                        {

                                    //the server
returned an error message which is in items[0]

                                    throw new
IllegalStateException(items[0]);

                        }

                        if(items.length != 4)

                        {

//the post returned is not in the format
//votername|date|votername|symbol

                                    throw new
IllegalStateException(“The post downloaded is in a wrong format”);

                       

                        //return a post built up
by the items extracted

                        return new
Post(items[0], items[1], items[2], items[3]);}

 

            //extract the itms of the post and
put them in a String array

            private String[] extractItems()

           

                        Vector v = new Vector();

                        //find the first
occurrence of the SPLITTER

                        int endIndex =
rawPost.indexOf(SPLITTER, index);

                        String item =
“”;

                        //extract the items
until the end of the last SPLITTER found in the rawPost string

                        while(endIndex != -1)

                        {

                                    item =
rawPost.substring(index, endIndex);

                                    index =
endIndex + 1;

                                    endIndex =
rawPost.indexOf(SPLITTER, index);

                                    v.addElement(item);

                        }

                        //extract the rest of
the rawPost (the text item)

                        item =
rawPost.substring(index);

                        v.addElement(item);

                        String[] ret = new
String[v.size()];

                        //copy
the content of the Vector in a string array

                        v.copyInto(ret);

                        return ret;

           

//RecordManager.java

package
com.alessandrolacava.wirelessblog.util;

import
javax.microedition.rms.*;

 

//Record
Stores Manager

public
class RecordManager

{

            private String rsName;

            private RecordStore rs;

           

            //contructor

            public RecordManager(String rsName)

            {

                        this.rsName = rsName;

            }

           

            //open a RS

            private void openRS()

            {

                        try {

                                    rs =
RecordStore.openRecordStore(rsName, true);

                        }

                        catch(Exception e)

                        {

                                    System.err.println(e);

                        }

            //close a RS

            private void closeRS()

            {

                        try {

                                    if(rs !=
null)

                                                rs.closeRecordStore();

                        }

                        catch(Exception e)

                        {

                                    System.err.println(e);

           

            //add a record to the RS

            public void addRecord(String record)

            {

                        openRS();

                       

                        byte[]
rec = record.getBytes();

                        try {

                                    rs.addRecord(rec,
0, rec.length);

                        }

                        catch(Exception e)

                        {

                                    System.err.println(e);

                        }

                        finally

                        {

                                    closeRS();

                       

            //replace a record in the RS

            public void setRecord(int id, String
record)

            {

                        openRS();

                       

                        byte[] rec =
record.getBytes();

                        try {

                                    rs.setRecord(id,
rec, 0, rec.length);

                        }

                        catch(Exception e)

                        {

                                    System.err.println(e);

                        }

                        finally

                        {

                                    closeRS();

                        }

            }

           

            //return a record of the RS

            public String getRecord(int id)

            {

                        openRS();

                        String ret =
“”;

                        try {

                                    ret = new
String(rs.getRecord(id));

                        }

                        catch(Exception e)

                        {

                                    System.err.println(e);

                        }

                        finally

                        {

                                    closeRS();

                        }

                        return ret;

                       

           

            //return the number of records
stored in the RS

            public int numRecords()

            {

                        openRS();

                        int num = -1;

                        try

                        {

                                    num =
rs.getNumRecords();

                        }

                        catch(Exception e)

                        {

                                    System.err.println(e);

                        }

                        finally

                        {

                                    closeRS();

                        }

                        return num;

            }

           

            //delete the RS

            public void deleteRS()

            {

                        try {

                                    RecordStore.deleteRecordStore(rsName);

                        }

                        catch(Exception e)

                        {

                                    System.err.println(e);

                       

 

We
also create some php file to store data from J2ME to MySQL database

 

//Config.inc

<?php

 

 

//DB parameters

 

$dbHost = “”;

$dbUser = “root”;

$dbPassword = “”;

$dbName =
“vote_db”;

 

//connect to the db

function connect()

{

            $db = mysql_connect($GLOBALS[“dbHost”],
$GLOBALS[“dbUser”], $GLOBALS[“dbPassword”]);

            if($db == false)

                        die(“Error while connecting to the
DB”);

            mysql_select_db($GLOBALS[“dbName”], $db)

                        or die(“Error while connecting to the
DB”);

            return $db;

}

 

?>

 

//login_sender.php

 

 

<?php

 

require(“config.inc.php”);

 

//retrieve data

$votername =
trim($_GET[“votername”]);

$voterid =
trim($_GET[“password”]);

$symbol =
trim($_GET[“symbol”]);

$phonenum =
trim($_GET[“phonenum”]);

 

//connect to the DB

$db = connect();

$lastdate =
“2007-11-21”;

$date1 =
date(“Y-m-d”);

if($lastdate<=$date1||$lastdate==$date1){

     echo “VOTEING TIME IS OVER”;

            die();

}

 

//set the query to check
the credentials

$query = “SELECT
votername, voterid, phonenum FROM votertable WHERE votername=’$votername’ AND
voterid=’$voterid’AND phonenum=’$phonenum'”;

 

//execute it

$result =
mysql_query($query, $db);

$query1 = “SELECT
votername, voterid FROM voterinformationtable WHERE votername=’$votername’ AND
voterid=’$voterid’AND phonenum=’$phonenum'”;

 

//execute it

$result1 =
mysql_query($query1, $db);

$num =
mysql_num_rows($result1);

 

if(mysql_num_rows($result)
== 0)

{

            // wrong credentials

            echo “WRONG VOTER NAME OR VOTERID OR PHONUMBER
“;

            die();

}

 

 

else if($num>=3)

{

            // wrong credentials

            echo “YOU HAVE ALREADY GIVEN 3 VOTES .\n SO IT IS
NOT POSSIBLE FOR YOU TO VOTE SOMEONE .\n”;

            die();

}

else

{

           

           

            $rest=3-$num;

            echo “YOU CAN GIVE “.($rest).” TIME
VOTES\n”;

           

}

 

mysql_close($db);

?>

 

//post_sender.php

 

 

<?php

 

require(“config.inc.php”);

 

//retrieve data

$votername =
trim($_GET[“votername”]);

$voterid =
trim($_GET[“password”]);

$symbol =
trim($_GET[“symbol”]);

$phonenum =
trim($_GET[“phonenum”]);

 

//connect to the DB

$db = connect();

 

$lastdate = “2007-11-21”;

$date1 =
date(“Y-m-d”);

if($lastdate<=$date1||$lastdate==$date1){

     echo “VOTEING TIME IS OVER”;

            die();

}

 

$query = “SELECT
votername, voterid FROM votertable WHERE votername=’$votername’ AND
voterid=’$voterid’AND phonenum=’$phonenum'”;

$query1 = “SELECT
votername, voterid FROM voterinformationtable WHERE votername=’$votername’ AND
voterid=’$voterid'”;

 

//execute it

$result =
mysql_query($query, $db);

$result1 =
mysql_query($query1, $db);

$num =
mysql_num_rows($result1);

if(mysql_num_rows($result)
== 0)

{

            // wrong credentials

            echo “WRONG VOTER NAME OR VOTERID OR PHONUMBER
“;

            die();

}

 

 else if($num>=3)

{

            // wrong credentials

            echo “YOU HAVE ALREADY GIVEN 3 VOTES .\n SO IT IS
NOT POSSIBLE FOR YOU TO VOTE SOMEONE .\n”;

            die();

}

else

{

           

           

            $rest=3-$num;

            echo “YOU CAN GIVE “.($rest-1).” TIME
VOTES\n”;

           

            //right credentials

            //retrieve the current date

            $date = date(“Y-m-d H:i:s”);

            $symbol = addslashes($symbol);

            $votername = addslashes($votername);

            //set the query

            $query = “INSERT INTO voterinformationtable(voterid,
postingDate, votername, symbol,phonenum) VALUES(‘$voterid’, ‘$date’,
‘$votername’, ‘$symbol’,’$phonenum’)”;

            //execute it

            $result = mysql_query($query, $db);

            if(!$result)

            {

                        echo “VOTE IS  NOT SENT.SO 
TRY AGAIN LATER .”;

            }

            else

            {

                        echo “VOTE IS SENT CORRECTLY .”;

            }

}

 

mysql_close($db);

?>

 

//post_retrieve.php

 

<?php

 

require(“config.inc.php”);

 

//retrieve the data

$votername =
trim($_GET[“votername”]);

$voterid =
trim($_GET[“password”]);

$voteri =
trim($_GET[“voterid”]);

$phonenum =
trim($_GET[“phonenum”]);

//connect to the DB

$db = connect();

$lastdate =
“2007-11-21”;

$date1 =
date(“Y-m-d”);

if($lastdate<=$date1||$lastdate==$date1){

     echo “VOTEING TIME IS OVER”;

            die();

}

 

//set the query to check
the credentials

$query = “SELECT
votername, voterid, phonenum FROM votertable WHERE votername=’$votername’ AND
voterid=’$voterid’AND phonenum=’$phonenum'”;

 

//execute the query

$result =
mysql_query($query, $db);

 

if(mysql_num_rows($result)
== 0)

{

            // wrong cedentials

            echo “WRONG VOTER NAME OR VOTERID OR PHONUMBER
“;

            die();

}

else

{

            //right credentials

           

            //set the query to extract the latest post form the
author $author

            $query = “SELECT voterid, postingDate, votername,
symbol FROM voterinformationtable WHERE voterid=’$voteri’ ORDER BY id DESC
LIMIT 0,1”;

            //execute it

            $result = mysql_query($query, $db);

            if(mysql_num_rows($result) == 0)

            {

                        echo “NO VOTE PRESENT FROM THIS
VOTER.”;

                        die();

            }

            else

            {

                        $rawPost = “”;

                        while(list($voterid, $postingDate,
$votername, $symbol) = mysql_fetch_array($result))

                        {

                                     $symbol = stripslashes($symbol);      

                                     //put the post in the for
votername|date|votername|symbol

                                     $rawPost .=
$votername.”|”.$postingDate.”|”.$votername.”|”.$symbol;                      

                        }

                        echo $rawPost;

           

 

            }

}

mysql_close($db); ?>

 

//result_retrieve.php

 

<?php

 

require(“config.inc.php”);

 

//retrieve the data

$votername =
trim($_GET[“votername”]);

$voterid =
trim($_GET[“password”]);

$voteri =
trim($_GET[“voterid”]);

$phonenum =
trim($_GET[“phonenum”]);

$symbol0=”RED”;

$symbol1=”WHITE”;

$symbol2=”BLUE”;

$symbol3=”GREEN”;

$symbol4=”BLACK”;

$num=0;

//connect to the DB

$db = connect();

$lastdate =
“2007-11-21”;

$date1 =
date(“Y-m-d”);

if($lastdate<=$date1||$lastdate==$date1){

     echo “VOTEING TIME IS OVER”;

            die();

}

 

//set the query to check
the credentials

$query = “SELECT
votername, voterid FROM votertable WHERE votername=’$votername’ AND
voterid=’$voteri’AND phonenum=’$phonenum'”;

 

//execute the query

$result =
mysql_query($query, $db);

 

if(mysql_num_rows($result)
== 0)

{

            // wrong cedentials

            echo “WRONG VOTER NAME OR VOTERID OR PHONUMBER
“;

            die();

}

else

{

            //right credentials

           

           

            $query = “SELECT symbol FROM voterinformationtable
WHERE symbol=’$symbol0′”;

            //execute it

            $result = mysql_query($query, $db);

            $num=mysql_num_rows($result);

                        echo ” “.$symbol0.” IS GOTTEN
—“.$num.” VOTES\n”;

                                   

            $query = “SELECT symbol FROM voterinformationtable
WHERE symbol=’$symbol1′”;

            //execute it

            $result = mysql_query($query, $db);

            $num=mysql_num_rows($result);

                        echo ” “.$symbol1.” IS GOTTEN
—“.$num.” VOTES\n”;

           

            $query = “SELECT symbol FROM voterinformationtable
WHERE symbol=’$symbol2′”;

            //execute it

            $result = mysql_query($query, $db);

            $num=mysql_num_rows($result);

                        echo ” “.$symbol2.” IS GOTTEN
—“.$num.” VOTES\n”;

           

            $query = “SELECT symbol FROM voterinformationtable
WHERE symbol=’$symbol3′”;

            //execute it

            $result = mysql_query($query, $db);

            $num=mysql_num_rows($result);

                        echo ” “.$symbol3.” IS GOTTEN
—“.$num.” VOTES\n”;

                                   

           

            $query = “SELECT symbol FROM voterinformationtable
WHERE symbol=’$symbol4′”;

            //execute it

            $result = mysql_query($query, $db);

            $num=mysql_num_rows($result);

                        echo ” “.$symbol4.” IS GOTTEN
—“.$num.” VOTES\n”;

                        die();

           

}

mysql_close($db);

?>

           

 

 

……………………………………………Code
is Finished………………………………………..

 

References

 

[1]  
http://today.java.net/pub/n/JavaWirelessToolkit2.3B-sun
java wireless          toolkid beta……………Sun java
wireless toolkit Beta2.3

[2]  
http://developers.sun.com/mobility/midp/articles/wtk23beta/-………………

[3]  
http://mobile3d.blogspot.com/2005/07/sun-java-wireless-toolkit-23-beta.html……………..

[4]  
http://en.wikipedia.org/wiki/MySQL………….MySQL

[5]  
http://www.webopedia.com/TERM/A/Apache_Web_server.htm……Apache
web server

[6]  
http://developers.sun.com/mobility/midp/questions/packages/index.html…….Java
packages

[7]  
 http://en.wikipedia.org/wiki/Handoff…….Handoff

[8]  
 http://developers.sun.com/mobility/getstart/……overview
of J2ME

[9]  
http://en.wikipedia.org/wiki/PHP……PHP

[10]                      
www.cs.helsinki.fi/u/kraatika/Courses/EVC-WINsummerschool/OMAoverview.pdf
……J2ME, CLDC, CDC, Profile

[11]                      
www.ifi.unizh.ch/~riedl/lectures/Java2001-j2me.pdf…….J2ME

[12]                      
http://developers.sun.com/mobility/midp/articles/wtk23beta/-………………

[13]                      
http://mobile3d.blogspot.com/2005/07/sun-java-wireless-toolkit-23-beta.html……………..

[14]                      
http://www.webopedia.com/TERM/J/JDK.html—-
JDK

[15]                      
http://www.manning.com/travis/-JDK 1.4

[16]                      
http://www.webopedia.com/TERM/A/Apache_Web_server.htm

[17]                      
Yu Feng and Dr.Jun Zhu
-‘Wireless Java Programming with J2ME’

[18]                      
James Keogh-‘ The
Complete Reference J2ME’

[19]                      
Dave W.Mercer, Allan
Kent, Steven D. Nowicki-‘Beginning PHP 5.’