wt mca journal+format
DESCRIPTION
web technologyTRANSCRIPT
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 1/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Paper II
Wireless Technology&
Mobile Computing
________________________________________________________________________
1 IDOL, University of Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 2/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
INDEX
Sr.No. Practical Description Page
No.
Date Sign
PART I – J2ME
1.Write a program in J2ME to perform thefollowing tasks:A] Draw a text box on the device screen.B] Change the background colour of the devicescreen.C] Change the colour of the text.D] Change the font style and font size of thedisplayed text.
4 20/10/2009
2. Write a program in J2ME to perform the simplecalculator operations such asa. Addition b. Subtractionc. Multiplicationd. Division
16 26/10/2009
3. Write a program in J2ME to create a simple Quizwhich content 3 to 4 questions and also displaythe score.
24 27/10/2009
4. Write a program in J2ME to create a currencyconverter and also display the result.
31 11/11/2009
5. Write a program in J2ME to generate a calendar. 35 16/11/2009
6. Write a program in J2ME to demonstrate simpleanimation through snake movement.
39 24/11/2009
________________________________________________________________________
2 IDOL, University of Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 3/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
7. Write a program in J2ME to create a simpledatabase application with an address book with
the following operations:a. Insert b. Deletec. Updated. Retrieve
44 25/11/2009
PART II – XHTML & WML
8. Develop a simple website using XHTML 51 02/12/2009
9. Develop a simple website using WML 60 02/12/2009
PART III – Demo Steps
10.File transfer between Laptop & Mobile phoneusing Bluetooth
69 04/12/2009
________________________________________________________________________
3 IDOL, University of Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 4/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 20/10/2009 PRACTICAL NO.1
AIM:
Write a program in J2ME to perform the following tasks:A] Draw a text box on the device screen.B] Change the background colour of the device screen.C] Change the colour of the text.D] Change the font style and font size of the displayed text.
DESCRIPTION:
javax.microedition.midlet
The MIDlet package defines Mobile Information Device Profile applications and the interactions
between the application and the environment in which the application runs. An application of theMobile Information Device Profile is a MIDlet.
The MIDlet lifecycle defines the protocol between a MIDlet and its environment through thefollowing:
• A simple well-defined state machine
• A concise definition of the MIDlet's states
• APIs to signal changes between the states
javax.microedition.lcdui
The UI API provides a set of features for implementation of user interfaces for MIDPapplications.
CommandListener
Description: This interface is implemented by listeners of commands fired from anadministration-client.
java.io
Provides for system input and output through data streams, serialization and the file system.
Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown.
java.util.Random
________________________________________________________________________
4 IDOL, University of Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 5/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Contains the collections framework, legacy collection classes, event model, date and timefacilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).
The TextBox Class
Beneath Alert, List, and Form, there is only one further subclass of Screen: the TextBox. The
TextBox allows the user to enter multi-line text on a separate screen. The constructor parameters
and the constraint constants are identical to those of TextField.
As for the currency list, you can also add a new screen enabling the user to enter a transfer
reason if desired. Similar to the CurrencyList, you implement a new class handling the
commands related to the new screen. However, this time it is derived from the TextBox
Foreground and Background Notifications
For several reasons, the Canvas may move into the background—for example, if the display is
set to another displayable object or if the device displays a system dialog. In these cases, the
Canvas is notified by the hideNotify() method. When the Canvas becomes visible (again), the
corresponding counterpart, showNotify(), is called.
Canvas
The Canvas abstract class extends Displayable. The Canvas class provides the paint() method as
well as some other methods that overriding them is the way for handling low level events
(similar to events handling in Java 1.0 before the emergence of the delegation model). When
using the Canvas class we extend it and override paint() (an abstract method).
The actual size of the screen varies from device to device. The screen dimension can be queried
by calling the getHeight() and the getWidth() methods.
Since the Canvas class extends Displayable it is possible adding commands to it as well as
registering it a CommandListener using the setCommandListener() method.
The declaration of the paint abstract method that was declared in Canvas is:
public void paint(Graphics g)
Color
Currently, most of the MIDP implementation (devices) usually do not support the use of colors
or just support a primitive color model (like 8 bit color model). Therefore, those MIDP ________________________________________________________________________
5 IDOL, University of Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 6/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
implementation simply map each of the colors that the midlet wants to one of the available
colors. Furthermore, the midlet also has the capability to check whether the device support color
representation by calling the Display.isColor() static method. The midlet can also check thenumber of colors the device support by calling the Display.numColors() static method. If the
device doesn’t support different colors the method will return the number of different grey
levels. The Graphics class has the following color related methods:
public int getColor()
public int getBlueComponent()
public int getGreenComponent()
public int getRedComponent()
public int getGrayScale()
public void setColor(int RGB)
public void setColor(int red, int green, int blue)
public setGrayScale(int value)
________________________________________________________________________
6 IDOL, University of Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 7/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
SOURCE CODE:
Program 1:
import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import java.io.*;import java.util.*;
public class ColorDemo extends MIDlet implements CommandListener {
Command cmdExit,cmdDisp;TextField txtFld;Form frm;
Display disp;ColorCanvas cc;
public void startApp(){
disp = Display.getDisplay(this);frm = new Form("Text Demo");disp.setCurrent(frm);frm.setCommandListener(this);
cmdExit=new Command("Exit",Command.EXIT,1);
frm.addCommand(cmdExit);
cmdDisp=new Command("Display",Command.SCREEN,1);frm.addCommand(cmdDisp);
txtFld=new TextField("","",100,TextField.ANY);frm.append(txtFld);
}
public void pauseApp(){} public void destroyApp(boolean flag){
notifyDestroyed();}
public void commandAction(Command c,Displayable d)
________________________________________________________________________
7 IDOL, University of Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 8/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
{if(c==cmdExit){
destroyApp(true);}
if(c==cmdDisp){
cc = new ColorCanvas(disp,txtFld.getString());disp.setCurrent(cc);
}}
}
Program 2:
import javax.microedition.lcdui.*;import javax.microedition.media.*;import java.io.*;
public class ColorCanvas extends Canvas implements CommandListener {
private int i;private Display display;
private int width, height;String str2;int j=1,bcol,fcol,sty;
private Command background = new Command("BACKGROUND",Command.SCREEN,1);
private Command textcolor = new Command("TEXTCOLOR",Command.SCREEN,1);
private Command fontstyle = new Command("CHANGE FONTSTYLE",Command.SCREEN,1);
private Command fontsize = new Command("CHANGE FONTSIZE",Command.SCREEN,1);
private Command change=new Command("CHANGE",Command.SCREEN,1);
static java.util.Random random = new java.util.Random();
public ColorCanvas(Display d,String str){
________________________________________________________________________
8 IDOL, University of Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 9/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
display = d;str2= str;this.addCommand(background);
this.addCommand(textcolor);this.addCommand(fontstyle);this.addCommand(fontsize);setCommandListener(this); bcol=random.nextInt()>>>1;fcol=random.nextInt()>>>1;repaint();
} protected void paint(Graphics g){
width = getWidth();
height = getHeight();g.setColor(bcol);g.fillRect(0,0, width, height);g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP |Graphics.LEFT);System.out.println("Case : "+i);switch(i){
case 1: bcol=random.nextInt()>>>1;g.setColor(bcol);
g.fillRect(0,0,width,height);g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT); break;
case 2:g.setColor(bcol);g.fillRect(0,0,width,height);fcol=random.nextInt()>>>1;g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT); break;
case 3:g.setColor(bcol);g.fillRect(0,0,width,height);
________________________________________________________________________
9 IDOL, University of Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 10/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
g.setFont(Font.getFont(Font.FACE_MO NOSPACE,Font.STYLE_ITALIC,Font.SIZE_SMALL));
sty=0;g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);break;
case 4:g.setColor(bcol);g.fillRect(0,0,width,height);g.setFont(Font.getFont(Font.FACE_ MONOSPACE,Font.STYLE_PLAIN,
Font.SIZE_SMALL));sty=1;g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);break;
case 5:g.setColor(bcol);g.fillRect(0,0,width,height);g.setFont(Font.getFont(Font.FACE_
MONOSPACE,Font.STYLE_ITALIC,Font.SIZE_SMALL));g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);break;
case 6:g.setColor(bcol);g.fillRect(0,0,width,height);g.setFont(Font.getFont(Font.FACE_ MONOSPACE,Font.STYLE_ITALIC,Font.SIZE_LARGE));g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);break;
________________________________________________________________________
10 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 11/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
case 7:g.setColor(bcol);g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_ MONOSPACE,Font.STYLE_PLAIN,Font.SIZE_SMALL));g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);break;
case 8:g.setColor(bcol);g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_ MONOSPACE,Font.STYLE_PLAIN,t.SIZE_LARGE));g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);break;
default: break;
}
} public void commandAction(Command c, Displayable d){
if (c==background){
i=1;repaint();
}else if(c==textcolor){
i=2;repaint();
}else if(c==fontstyle){
if(j==1){
i=3;
________________________________________________________________________
11 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 12/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
sty=0; j=0;
}
else{ j=1;sty=1;i=4;
}repaint();
}else if(c==fontsize){
if(j==1 && sty==1)
{ i=5;sty=0;
}else if(j==1 && sty==0){
i=6;sty=1;
}else if(j==0 && sty==1){
i=7;sty=0;}else if(j==0 && sty==0){
i=8;sty=1;
}}
} public void pauseApp(){} public void destroyApp(boolean unconditional){}
}
________________________________________________________________________
12 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 13/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
OUTPUT:
Draw a text box on the device screen.
________________________________________________________________________
13 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 14/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Change the background colour of the device screen.
________________________________________________________________________
14 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 15/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Change the colour of the text.
________________________________________________________________________
15 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 16/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Change the font style and font size of the displayed text.
________________________________________________________________________
16 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 17/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
________________________________________________________________________
17 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 18/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 26/10/2009 PRACTICAL NO.2
AIM:
Write a program in J2ME to perform the simple calculator operations such asa. Addition b. Subtractionc. Multiplicationd. Division
DESCRIPTION:
Designing the new form
DetailForm extends the Form base class (which itself extends Screen, so it can contain other
components) and implements both the commandListener and ItemStateListener interfaces,allowing it to handle its own events. If you've looked at the code already, you may have noticed a
setDestroyListener method in DetailForm's API, which accepts an instance of a class
implementing the custom DestroyListener interface. By imitating the event notification
mechanism used by lcdui like this, I can notify DetailForm's controlling MIDlet that the user has
finished using the form. When the MIDlet receives this event, it can use Display.setCurrent to
activate another Screen component.
The most important subclass of Screen is the class Form. A Form can hold any number of Items
such as StringItems, TextFields, and ChoiceGroups. Items can be added to the Form using the
append() method.
The Item class itself is an abstract base class that cannot be instantiated. It provides a label that is
a common property of all subclasses. The label can be set and queried using the setLabel()and
getLabel() methods, respectively. The label is optional, and a null value indicates that the item
does not have a label. However, several widgets switch to separate screens for user interaction,
where the label is used as the title of the screen. In order to allow the user to keep track of the
program state, it is recommended that you provide a label at least for interactive items.
The TextFields
The TextField component displays and allows editing of text, similar to a text box control in a
desktop application. TextFields support some rudimentary input constraints, which are set when
the component is created by the final constructor argument. In addition to restricting input, these
________________________________________________________________________
18 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 19/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
constraints can simplify data entry with a phone-style number pad by recognizing only certain
specific characters for a given key (only numbers for a numeric field, for example). The possible
constraint values are:
• TextField.ANY: Anything goes; text, special characters, and numeric values are all okay.
• TextField.EMAILADDR: Only characters that can make up valid e-mail addresses are
allowed.
• TextField.NUMERIC: Only numeric values are allowed. Remember that there is no
support for floating-point numbers in MIDP, so this constraint will allow only whole
numbers.
• TextField.PASSWORD: This provides the traditional "replace everything the user enters
with an asterisk (*)" treatment for passwords.
• TextField.PHONENUMBER: Only entries that would make valid parts of a phone
number are allowed.
• TextField.URL: Only characters that could be legally contained in a URL are allowed.
________________________________________________________________________
19 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 20/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
SOURCE CODE:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*; public class Calc extends MIDlet implements CommandListener {
Display disp;TextField tf1,tf2,tf3;Form form;Command add,sub,mul,div,mod,exit;public Calc(){
disp=Display.getDisplay(this);form=new Form("Operation on Two Nos. ");
tf1=new TextField("First no.","0",30,TextField.ANY);tf2=new TextField("Second no.","0",30,TextField.ANY);tf3=new TextField("Result","0",30,TextField.ANY);form.append(tf1);form.append(tf2);form.append(tf3);add=new Command("add",Command.SCREEN,1);sub=new Command("subtract",Command.SCREEN,1);mul=new Command("multiply",Command.SCREEN,1);div=new Command("Divide",Command.SCREEN,1);mod=new Command("modulus",Command.SCREEN,1);
exit=new Command("Exit",Command.EXIT,2);form.addCommand(add);form.addCommand(sub);form.addCommand(mul);form.addCommand(div);form.addCommand(mod);form.addCommand(exit);form.setCommandListener(this);
} public void startApp(){
disp.setCurrent(form);} public void pauseApp(){} public void destroyApp(boolean unconditional){}
________________________________________________________________________
20 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 21/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
public void commandAction(Command c,Displayable d){
if(c==add){int a=Integer.parseInt(tf1.getString());int b=Integer.parseInt(tf2.getString());int c1=a+b;tf3.setString(String.valueOf(c1));
}if(c==sub){
int a=Integer.parseInt(tf1.getString());int b=Integer.parseInt(tf2.getString());
int c1=a-b;tf3.setString(String.valueOf(c1));}if(c==mul){
int a=Integer.parseInt(tf1.getString());int b=Integer.parseInt(tf2.getString());int c1=a*b;tf3.setString(String.valueOf(c1));
}if(c==div)
{ int a=Integer.parseInt(tf1.getString());int b=Integer.parseInt(tf2.getString());if(b==0)
tf3.setString("Divisor cannot be zero");else{int c1=a/b;tf3.setString(String.valueOf(c1));}
}if(c==mod){
int a=Integer.parseInt(tf1.getString());int b=Integer.parseInt(tf2.getString());if(b==0)
tf3.setString("Divisor cannot be zero");else
________________________________________________________________________
21 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 22/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
{int c1=a%b;tf3.setString(String.valueOf(c1));
}}if(c==exit){
destroyApp(false);notifyDestroyed();
}}
}
________________________________________________________________________
22 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 23/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
OUTPUT:
________________________________________________________________________
23 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 24/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Addition
________________________________________________________________________
24 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 25/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Subtraction
________________________________________________________________________
25 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 26/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Multiplication
Division
________________________________________________________________________
26 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 27/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
________________________________________________________________________
27 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 28/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 27/10/2009 PRACTICAL NO.3
AIM: Write a program in J2ME to create a simple Quiz which content 3 to 4 questions and also
display the score.
DESCRIPTION:
java.lang
Provides classes that are fundamental to the design of the Java programming language. The mostimportant classes are Object, which is the root of the class hierarchy, and Class, instances of which represent classes at run time.
Frequently it is necessary to represent a value of primitive type as if it were an object. Thewrapper classes Boolean, Character, Integer, Long, Float, and Double serve this purpose. Anobject of type Double, for example, contains a field whose type is double, representing that valuein such a way that a reference to it can be stored in a variable of reference type. These classesalso provide a number of methods for converting among primitive values, as well as supportingsuch standard methods as equals and hashCode. The Void class is a non-instantiable class thatholds a reference to a Class object represening the primitive type void.
The class Math provides commonly used mathematical functions such as sine, cosine, and squareroot. The classes String and StringBuffer similarly provide commonly used operations oncharacter strings.
Classes ClassLoader, Process, Runtime, SecurityManager, and System provide "systemoperations" that manage the dynamic loading of classes, creation of external processes, hostenvironment inquiries such as the time of day, and enforcement of security policies.
Class Throwable encompasses objects that may be thrown by the throw statement . Subclasses of Throwable represent errors and exceptions
ItemStateListener
This interface is used by applications which need to receive events that indicate changes in the
internal state of the interactive items within a Form screen.
Classes implementing the ItemStateListener interface are able to receive notifications for the
following events:
• State changes of a ChoiceGroup
________________________________________________________________________
28 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 29/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
• Value adjustments of an interactive Gauge
• TextField value changes
• DateField changes
The events are sent to the method itemStateChanged() of the ItemStateListener, where the item
that has changed is given as a parameter. In order to actually receive these events, the
ItemStateChangeListener must be registered using the setItemStateListener() method of the
corresponding Form.
________________________________________________________________________
29 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 30/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
SOURCE CODE:
import javax.microedition.midlet.*;import javax.microedition.lcdui.*;
import java.lang.*;
public class QuizDemo extends MIDlet implements CommandListener,ItemStateListener {
private Display disp; private Form form1,form2,form3,form4; private Command exit,next1,next2,next3,submit; private TextBox msg; private Item selection; private ChoiceGroup radiobuttons,rdb2,rdb3,rdb4;
StringItem ms1,ms2,ms3,ms4; private int defaultIndex; private int radioButtonIndex;int flag=0;
public QuizDemo(){
disp=Display.getDisplay(this);
ms1=new StringItem(null,"Which following city is capital of India ?");
radiobuttons=new ChoiceGroup("Select your answer",Choice.EXCLUSIVE);radiobuttons.append("Bangalore",null);radiobuttons.append("Delhi",null);radiobuttons.append("Mumbai",null);radiobuttons.append("Pune",null);
ms2=new StringItem(null,"Which following city is capital of Japan? ");
rdb2=new ChoiceGroup("Select your answer",Choice.EXCLUSIVE);rdb2.append("Ya ka nua",null);rdb2.append("Bijieng",null);rdb2.append("Tokiyo",null);rdb2.append("ku do su",null);
ms3=new StringItem(null,"Which following city is capital of UK? ");
rdb3=new ChoiceGroup("Select your answer",Choice.EXCLUSIVE);
________________________________________________________________________
30 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 31/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
rdb3.append("Amsterdam",null);rdb3.append("London",null);rdb3.append("New York",null);
rdb3.append("Mexico",null);
ms4=new StringItem(null,"Which following city is capital of Egypt? ");
rdb4=new ChoiceGroup("Select your answer",Choice.EXCLUSIVE);rdb4.append("Peru",null);rdb4.append("Rome",null);rdb4.append("Kairo",null);rdb4.append("Sydney",null);
form1=new Form("Question 1");
form1.append(ms1);radioButtonIndex=form1.append(radiobuttons);form2=new Form("Question 2");form2.append(ms2);radioButtonIndex=form2.append(rdb2);form3=new Form("Question 3");form3.append(ms3);radioButtonIndex=form3.append(rdb3);form4=new Form("Question 4");form4.append(ms4);radioButtonIndex=form4.append(rdb4);
exit=new Command("Exit",Command.EXIT,1);submit=new Command("Submit",Command.SCREEN,2);next1=new Command("Next",Command.SCREEN,1);next2=new Command("Next",Command.SCREEN,1);next3=new Command("Next",Command.SCREEN,1);msg=new TextBox("Message","Congrats",80,0);
form1.addCommand(next1);form2.addCommand(next2);form3.addCommand(next3);form4.addCommand(submit);form4.addCommand(exit);form1.setCommandListener(this);form2.setCommandListener(this);form3.setCommandListener(this);form4.setCommandListener(this);
________________________________________________________________________
31 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 32/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
form1.setItemStateListener(this);form2.setItemStateListener(this);form3.setItemStateListener(this);
form4.setItemStateListener(this);}
public void startApp(){
disp.setCurrent(form1);}
public void pauseApp(){
} public void destroyApp(boolean unconditional){
}
public void itemStateChanged(Item item){
if(item==radiobuttons){
String
ans=(radiobuttons.getString(radiobuttons.getSelectedIndex()));if(ans.equals("Delhi")){
flag++;}
}if(item==rdb2){
String ans=(rdb2.getString(rdb2.getSelectedIndex()));if(ans.equals("Tokiyo")){
flag++;}
}if(item==rdb3){
________________________________________________________________________
32 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 33/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
String ans=(rdb3.getString(rdb3.getSelectedIndex()));if(ans.equals("London")){
flag++;}
}if(item==rdb4){
String ans=(rdb4.getString(rdb4.getSelectedIndex()));if(ans.equals("Kairo")){
flag++;}
}
}
public void commandAction(Command com,Displayable disp1){
if(com==next1){
disp.setCurrent(form2);}
if(com==next2){disp.setCurrent(form3);
}if(com==next3){
disp.setCurrent(form4);}if(com==exit){
destroyApp(false);notifyDestroyed();
}if(com==submit){
//disp.setCurrent(msg);StringItem msg1=new StringItem(null," You have Correct
Answer" +flag);
________________________________________________________________________
33 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 34/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
form4.append(msg1);}
}
}
________________________________________________________________________
34 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 35/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
OUTPUT:
________________________________________________________________________
35 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 36/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 11/11/2009 PRACTICAL NO.4
AIM: Write a program in J2ME to create a currency converter and also display the result.
DESCRIPTION:
notifyDestroyed
The javax.microedition.midlet.MIDlet class also defines methods that let a MIDlet interact withits operating context: getAppProperty() returns initialization property values; resumeRequest()asks the AMS to reactivate the MIDlet; notifyPaused() shifts the MIDlet to the paused state; andnotifyDestroyed() shifts the MIDlet to the destroyed state.
MIDlet initialization properties are name-value pairs in the MIDlet's application descriptor or in
its manifest. The application descriptor is a separate text file that lists important informationabout a set of MIDlets packaged together into a single JAR file (a MIDlet suite). The manifest isthe standard JAR manifest packaged with the MIDlet suite. When getAppProperty() is invoked,it searches the application descriptor first, then the manifest. (Note that MIDP 2.0 introduces theconcept of trusted suites, in which case getAppProperty() searches only the manifest.)
The remaining methods directly affect the MIDlet's life-cycle. A paused MIDlet callsresumeRequest() to be reactivated. An active MIDlet calls notifyPaused() to be deactivated. A paused or active MIDlet calls notifyDestroyed() to be destroyed. Note that resumeRequest()merely asks the AMS to reactivate the MIDlet; the AMS decides whether and when to reactivatethe MIDlet. Reactivation invokes the MIDlet's startApp() method. By contrast, notifyPaused() or notifyDestroyed() causes an immediate transition to the new state; as a consequence, neither pauseApp() nor destroyApp() is invoked.
________________________________________________________________________
36 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 37/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
SOURCE CODE:
import javax.microedition.midlet.*;import javax.microedition.lcdui.*;
public class Currency extends MIDlet implements CommandListener {
private Display disp; private Form f; private TextField tb; private TextField tb1; private ChoiceGroup cg,cg1; private Command resul; private Command ans; public Currency()
{ tb = new TextField("","",20,TextField.NUMERIC);tb1 = new TextField("Result","Answer",10,TextField.ANY);resul = new Command("Result", Command.SCREEN, 1);
String[] str1 = { "Pound", "Euro", "Dollar","Yen" };String[] str = { "Rupee" };cg = new ChoiceGroup("", Choice.POPUP, str, null);cg1 = new ChoiceGroup("", Choice.POPUP, str1, null);
f = new Form("Currency Convertor");
f.append(cg);f.append(tb);f.append(cg1);f.append(tb1);f.addCommand(resul);f.setCommandListener(this);
}
public void startApp(){
disp = Display.getDisplay(this);disp.setCurrent(f);
}
public void pauseApp(){}
________________________________________________________________________
37 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 38/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
public void destroyApp(boolean unconditional){}
public void commandAction(Command c, Displayable s){int n,n1,res=0;String res1;
n=cg1.getSelectedIndex();n1=Integer.parseInt(tb.getString());
switch(n){
case 0:
res = n1/85; break;case 1:
res= n1/75; break;
case 2:res=n1/48; break;
case 3:res=n1*2; break;
}res1=Integer.toString(res);System.out.println("first="+n1+"\nOperation Index="+n+"\nResult="+res);tb1.setString(res1);
}}
________________________________________________________________________
38 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 39/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
OUTPUT:
________________________________________________________________________
39 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 40/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
________________________________________________________________________
40 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 41/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 16/11/2009 PRACTICAL NO.5
AIM: Write a program in J2ME to generate a calendar.
DESCRIPTION:
java.util.Date
A Date object represents a precise moment in time, down to the millisecond. Dates arerepresented as a long that counts the number of milliseconds since midnight, January 1, 1970,Greenwich Mean Time.
the class Date had two additional functions. It allowed the interpretation of dates as year, month,day, hour, minute, and second values. It also allowed the formatting and parsing of date
strings. Unfortunately, the API for these functions was not amenable tointernationalization. As of JDK 1.1, the Calendar class should be used to convert betweendates and time fields and the DateFormat class should be used to format and parse datestrings. The corresponding methods in Date are deprecated
DateField
Now you have used all the Item subclasses except Gauge and DateField. Both classes are
specialized input elements, where the Gauge may also make sense as a pure read-only
information item.
The Gauge item visualizes an integer value by displaying a horizontal bar. It is initialized with alabel, a flag indicating whether it is interactive, and a maximum and an initial value. If a Gauge
is interactive, the user is allowed to change the value using a device-dependent input method.
Changes to the gauge value will cause ItemEvents if a corresponding listener is registered to the
form.
The following code snippet shows the construction of a non-interactive Gauge labeled Progress
that is initialized with a value of 0 and a maximum of 100:
Gauge gauge = new Gauge ("Progress", false, 0, 100);
If a Gauge is used to display progress of a process that takes a longer amount of time, you should
also add a corresponding Stop command to the form to abort the progress.
________________________________________________________________________
41 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 42/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
The current value of the Gauge can be set using the method setValue() and read using the
method getValue(). Analogous setMaxValue() and getMaxValue() methods let you access the
maximum value of the Gauge.
The DateField is a specialized widget for entering date and time information in a simple way. It
can be used to enter a date, a time, or both types of information at once. The appearance of the
DateField is specified using three possible input mode constants in the constructor. Possible
DateField mode constants are listed in Table 3.6.
Table 3.6 DateField Mode Constants
Constant Value
DATE Passed if the DateField should be used for entering a date only.
DATE_TIME Used for creating a DateField to enter both date and time information.
TIME Used to enter time information only.
The DateField has two constructors in which a label and the mode can be specified. Using the
second constructor, an additional TimeZone can be passed. The following code snippet shows
how a DateField for entering the date of birth can be initialized:
DateField dateOfBirth = new DateField ("Date of birth:", DateField.DATE);
After you enter the date into the DateField, it can be accessed using the getDate() method. The
DateField offers some additional methods for getting information about the input mode andmethods for setting the date and the input mode as well.
________________________________________________________________________
42 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 43/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
SOURCE CODE:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;import java.util.Date;
public class CalenderMIDlet extends MIDlet{
private Form form; private Display disp; private DateField cal; private static final int DATE=0;
public CalenderMIDlet()
{ cal=new DateField("Date In",DateField.DATE);
}
public void startApp(){
disp=Display.getDisplay(this);form=new Form("Calender");form.append(cal);disp.setCurrent(form);
}
public void pauseApp(){
}
public void destroyApp(boolean unconditional){
}}
________________________________________________________________________
43 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 44/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
OUTPUT:
________________________________________________________________________
44 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 45/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 24/11/2009 PRACTICAL NO.6
AIM: Write a program in J2ME to demonstrate simple animation through snake movement.
DESCRIPTION:
Animation
With animation, there are normally two main problems: Display flickering and synchronization
of painting with calculation of new frames. We will first address how to get the actual painting
and application logic in sync, and then solve possible flickering.
Synchronization of Frame Calculation and Drawing
When you perform animations, you can first calculate the display content and then call repaint()
in order to paint the new frame. But how do you know that the call to paint() has finished? One
possibility would be to call serviceRepaints(), which blocks until all pending display updates are
finished. The problem with serviceRepaints() is that paint() may be called from another thread. If
the thread calling serviceRepaints() holds any locks that are required in paint(), a deadlock may
occur. Also, calling serviceRepaints() makes sense only from a thread other than the event
handling thread. Otherwise, key events may be blocked until the animation is over. An
alternative to serviceRepaints() is calling callSerially() at the end of the paint() method. ThecallSerially() method lets you put Runnable objects in the event queue. The run() method of the
Runnable object is then executed serially like any other event handling method. In the run()
method, the next frame can be set up, and a new repaint can be requested there.
To demonstrate this execution model, you will build a simple stopwatch that counts down agiven number of seconds by showing a corresponding pie slice using the fillArc() methodThe Canvas implementation stores the current slice in degree, the start time, the total amount of seconds and the MIDlet display in local variables. In order to make use of callSerially(), your Canvas implements the Runnable interface
________________________________________________________________________
45 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 46/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
SOURCE CODE:
import javax.microedition.midlet.*;import javax.microedition.lcdui.*;
public class MySnake extends MIDlet implements CommandListener {
DrawSnake ds;Display dis;
public MySnake(){
dis=Display.getDisplay(this);ds=new DrawSnake();
}
public void startApp(){
dis.setCurrent(ds);}
public void commandAction(Command c,Displayable d){}
public void pauseApp(){}
public void destroyApp(boolean unconditional){}
}
class DrawSnake extends Canvas implements Runnable, CommandListener {
int x,y,dir;Thread th;Command quit;
public DrawSnake(){x=0;y=0;dir=0;quit=new Command("QUIT",Command.SCREEN,1);addCommand(quit);
________________________________________________________________________
46 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 47/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
setCommandListener(this);th=new Thread(this);th.start();
}
public void commandAction(Command c,Displayable d){
if(c==quit){}//notifyDestroyed();
}
public void keyPressed(int cd){
switch(getGameAction(cd)){case Canvas.UP:y-=5;dir=1;
break;case Canvas.DOWN:y+=5;
dir=2;break;
case Canvas.LEFT:
x-=5;dir=3;break;
case Canvas.RIGHT:x+=5;
dir=4;break;
}
}
public void run(){while(true){if(dir==1)y-=5;else if(dir==2)
________________________________________________________________________
47 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 48/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
y+=5;else if(dir==3)x-=5;
else if(dir==4)x+=5;
repaint();try{th.sleep(500);}catch (Exception ee){
}
}}
public void paint(Graphics g){
g.setColor(0x1F2F1F);g.fillRect(x, y, 10, 10);
g.drawString("RUPAK RAUSHAN",25,25, Graphics.TOP | Graphics.LEFT);}}
________________________________________________________________________
48 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 49/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
OUTPUT:
________________________________________________________________________
49 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 50/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 25/11/2009 PRACTICAL NO.7
AIM:
Write a program in J2ME to create a simple database application with an address book with the following operations:a. Insert b. Deletec. Updated. Retrieve
DESCRIPTION:
javax.microedition.io Description
Provides a simplified mechanism for applications to use various types of I/O protocols inresource-constrained environments. I/O is performed by means of Connections obtained throughthe Connector factory class. Connections are dynamically created based on URIs of the form:{scheme}:[{target}][{params}] Please see the Connector class for more information
Runnable Interface
• The other way to implement a thread is to implement a class that implements the
Runnable interface.• This is very useful when you want your class to extend some other class.
• You must implement the run() method.
DBConnCLDC framework, do not support JDBC APIS. To connect to databases from devices thathave CLDC configuration, you can call a Servlet from MIDLets. Connection to database,running the queries and other functionalities need to be implemented in the Servlet.Passing the parameters to servlet like username, password can be done from MIDLets.
HttpConnection
This J2ME example will cover reading data using the MIDP HttpConnection. Note that this
connection interface is not part of the CLDC or CDC, but is defined rather in the MIDP and
Personal Profiles themselves. The behavior of HttpConnection is one that combines an
InputStream and an OutputStream into a single connection. A single HttpConnection mayopen and use exactly one OutputStream and exactly one InputStream. The order in which
the streams are used is important as well. The OutputStream, if used, must be used before
the InputStream. Once the streams have been used the connection should be closed and a
________________________________________________________________________
50 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 51/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
new HttpConnection should be opened to continue communications if necessary. This
follows the HTTP request-response paradigm.
The HttpConnection is a bit more tricky to use than the socket or datagram connections
because there is a lot that happens behind the scenes. There are three states to an
HttpConnection:
• Setup
• Connected
• Closed
The setup state is the first state encountered after a connection is opened. While in this state,
connection parameters can be set such as the request method (GET, POST or HEAD) using thesetRequestMethod() method or any header properties using the setRequestProperty() method.
The transition from setup to connected is triggered by any methods that cause data to be sent
to the server. The following is a list of methods that cause this transition.
• openInputStream
• openDataInputStream
• getLength
• getType
• getEncoding
• getHeaderField
• getResponseCode
• getResponseMessage
• getHeaderFieldInt
• getHeaderFieldDate
• getExpiration
• getDate
•
getLastModified• getHeaderField
• getHeaderFieldKey
________________________________________________________________________
51 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 52/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Once the connection transitions to the connected state, any calls to setRequestMethod() andsetRequestProperty() will throw an IOException. The state transition from setup to connectedreflects the underlying handshake of the HttpConnection as headers are sent to the server and the
connection prepares to send data.
________________________________________________________________________
52 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 53/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
SOURCE CODE:
import java.io.*;
import java.util.*;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.io.*;
public class MySQLConn extends MIDlet implements CommandListener {private String username;private String url = "http://localhost:8086/servlets-examples/get";private Display display;private Command exit = new Command("EXIT", Command.EXIT, 1);;private Command connect = new Command("Connect", Command.SCREEN, 1);
private Form menu;private TextField tb1;private TextField tb2;DBConn db;
public MySQLConn() throws Exception {display = Display.getDisplay(this);
}
public void startApp() {displayMenu();}
public void displayMenu() {menu = new Form("Connect");tb1 = new TextField("Please input username: ","",30,TextField.ANY);tb2 = new TextField("Please input password: ","",30,TextField.PASSWORD);menu.append(tb1);menu.append(tb2);menu.addCommand(exit);menu.addCommand(connect);menu.setCommandListener(this);display.setCurrent(menu);
}
public void pauseApp() {}
________________________________________________________________________
53 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 54/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
public void destroyApp(boolean unconditional) {}
public void commandAction(Command command, Displayable screen) {
if (command == exit) {destroyApp(false);notifyDestroyed();
} else if (command == con) {db = new DBConn(this);db.start();db.connectDb(tb1.getString(),tb2.getString());
}}
public class DBConn implements Runnable {
MySQLConn midlet;private Display display;String db;String user;String pwd;public DBConn(MySQLConn midlet) {
this.midlet = midlet;display = Display.getDisplay(midlet);
}
public void start() {
Thread t = new Thread(this);t.start();}
public void run() {StringBuffer sb = new StringBuffer();try {
HttpConnection c = (HttpConnection) Connector.open(url);c.setRequestProperty("User-Agent","Profile/MIDP-1.0,
Configuration/CLDC-1.0");c.setRequestProperty("Content-Language","en-US");c.setRequestMethod(HttpConnection.POST);DataOutputStream os =
(DataOutputStream)c.openDataOutputStream();
//os.writeUTF(db.trim());os.writeUTF(user.trim());os.writeUTF(pwd.trim());
________________________________________________________________________
54 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 55/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
os.flush();os.close();
// Get the response from the servlet page.DataInputStream is =(DataInputStream)c.openDataInputStream();//is = c.openInputStream();int ch;sb = new StringBuffer();while ((ch = is.read()) != -1) {
sb.append((char)ch);}showAlert(sb.toString());is.close();c.close();
} catch (Exception e) {showAlert(e.getMessage());}
}/* This method takes input from user like db,user and pwd and pass to servlet
*/public void connectDb(String user,String pwd) {
//this.db = db;this.user = user;this.pwd = pwd;
}
/* Display Error On screen*/private void showAlert(String err) {
Alert a = new Alert("");a.setString(err);a.setTimeout(Alert.FOREVER);display.setCurrent(a);
}};
}
Servlet Codeimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;import java.sql.*;
public class GetConnection extends HttpServlet
________________________________________________________________________
55 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 56/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
{Connection conn;
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html");
PrintWriter out = response.getWriter();DataInputStream in = new DataInputStream((InputStream)request.getInputStream());
String user = in.readUTF();String pwd = in.readUTF();System.out.println("received data is==>"+user+pwd);try
{
// connect(user.toLowerCase().trim(), pwd.toLowerCase().trim());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");conn = DriverManager.getConnection("jdbc:odbc:Harshad");Statement stmt = conn.createStatement();int i = stmt.executeUpdate("insert into Login values('"+user+"','"+pwd+"')");if(i!=0)
{out.println("data has been inserted");
}else{out.println("data is not inserted");}
}catch(Exception e){ e.printStackTrace(); }
out.println("Data:"+user+pwd);in.close();
out.close();out.flush();
}
________________________________________________________________________
56 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 57/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doPost(request,response);
}/* private void connect( String user,String pwd) throws Exception {
}*/}
OUTPUT:
________________________________________________________________________
57 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 58/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
________________________________________________________________________
58 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 59/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 02/12/2009 PRACTICAL NO.8
AIM: Develop a simple website using XHTML
DESCRIPTION:
XHTML
XHTML was developed to make HTML more extensible and increase interoperability with other data formats. By shifting to an XML format, it was hoped HTML would become compatiblewith common XML tools; servers and proxies would be able to transform content, as necessary,for constrained devices such as mobile phones.The only essential difference between XHTML and HTML is that XHTML must be well-formedXML, while HTML need not be.
XHTML (Extensible Hypertext Markup Language) must always contain both a beginning and aclosing tag. Most often this is done by writing two fully separate tags. However, it is alsosometimes done by using a backwards slash within the opening tag. For example, the tag <hr />is used to create a horizontal line. This tag is self-closing so it is not necessary to write a separatetag using the backwards slash to end it.
Between the <title> and </title> tags, give the web page a name, which will appear at the verytop of the page when it is viewed using a web browser.
Next, page content will be inserted between the <body> and </body> tags.
To easily create a large heading, the tags <h1> and </h1> are used to format content placed between them. Underneath the <body> tag, type <h1>Welcome to my Web Page</h1>.
Next, under the </h1> tag, type the following table name: <h2> Vacation Photos:</h2>.
To stylize a simple web page, the use of internal CSS is convenient. Place code between the<head> and the <body> tags to stylize the page.
________________________________________________________________________
59 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 60/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
SOURCE CODE:
index.xhtml
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>C Tutorial by Chetan</title></head>
<body>
<center><img src="front1.gif" alt="Image cannot be displayed" /></center>
<h1>Index</h1>C is a programming language developed at AT & T's Bell Laboratories of USA in 1972. Itwas designed and written by Dennis Ritchie. C seems to be so popular because it is reliable,simple and easy to use.
<ol><li><a href="lesson1.xhtml">Getting Started</a></li>
<li><a href="lesson2.xhtml">Decision Control Structure</a></li>
<li><a href="lesson3.xhtml">Loop Control Structure</a></li><li><a href="lesson5.xhtml">Case Control Structure</a></li><li><a href="lesson4.xhtml">Functions</a></li>
<li><a href="lesson6.xhtml">Pointers</a></li><li><a href="lesson7.xhtml">Structures</a></li>
<li><a href="lesson8.xhtml">Arrays</a></li><li><a href="lesson9.xhtml">Puppetting On Strings</a></li><li><a href="lesson10.xhtml">Typecasting</a></li><li><a href="lesson11.xhtml">Command Line Arguments</a></li>
</ol>
</body></html>
________________________________________________________________________
60 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 61/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
lesson1.xhtml
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"><head><title> Lesson 1 of C Tutorial</title></head>
<body><Center><h1>Getting Started</h1></center>
<h2>Hello World Program</h2>
Every full C program begins inside a function called "main". A function is simply a collection of commands that do "something". The main function is always called when the program firstexecutes. From main, we can call other functions, whether they are written by us or by others or use built-in language features. To access the standard functions that comes with your compiler,you need to include a header with the #include directive. What this does is effectively takeeverything in the header and paste it into your program.
<pre class="example">#include <stdio.h>int main(){
printf("Hello World \n Welcome to C Programming");return 0;}</pre> Let's look at the elements of the program. The #include is a "preprocessor" directive that tells thecompiler to put code from the header called stdio.h into our program before actually creating theexecutable. By including header files, you can gain access to many different library functionslike printf etc. The semicolon is part of the syntax of C. It tells the compiler that you are at theend of a command. The next imporant line is int main(). This line tells the compiler that thereis afunction named main, and that the function returns an integer.The "curly braces" ({ and }) signalthe beginning and end of functions and other code blocks. The printf function is the standard Cway of displaying output on the screen. The quotes tell the compiler that you want to output theliteral string as it is. The '\n' sequence is actually treated as a single character that stands for anewline. Finally, at the end of the program, we return a value from main to the operating system by using the return statement. This return value is important as it can be used to tell the operatingsystem whether our program succeeded or not. A return value of 0 means success. The final brace closes off the function.
________________________________________________________________________
61 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 62/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
<h2>Using Variables</h2>
In C, input and data are stored in variables. There are several different types of variables; whenyou tell the compiler you are declaring a variable, you must include the data type along with thename of the variable. Several basic types include char, int, and float. Each type can storedifferent types of data. A variable of type char stores a single character, variables of type intstore integers (numbers without decimal places), and variables of type float store numbers withdecimal places. Each of these variable types - char, int, and float - is each a keyword that you usewhen you declare a variable. Before you can use a variable, you must tell the compiler about it by declaring it and telling the compiler about what its "type" is. To declare a variable you usethe syntax <variable type> <name of variable>; For instance, a basic variable
declarationmight look like this:
<pre class="example">int myVariable;</pre>
<h2>Reading input</h2>
<pre class="example">
#include <stdio.h>
int main(){
int number;
printf( "Please enter a number: " );scanf( "%d", &number );printf( "You entered %d", number );return 0;
}</pre>
The #include and main function before; main must appear in every program you intend to run,and the #include gives us access to printf as well as scanf. The io in stdio.h stands for "input/output"; std just stands for "standard". The keyword int declares number to be an integer.The printf function is udes to display strings and scanf function is used to receive input from theuser.
________________________________________________________________________
62 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 63/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
</br></br><a href="index.xhtml">HOME</a> <a
href="lesson2.xhtml">NEXT</a></body></html>lesson3.xhtml
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"><head><title> Lesson 2 of C Tutorial</title></head>
<body>
<Center><h1>Decision Control Structure</h1></center>
<h2>If Syntax</h2>
The structure of an if statement is as follows:<pre class="example">if (condition){
// if condition is true then this block is executed}</pre>
Here is a simple example:<pre class="example">if( 5 < 10 ){
printf("Five is less than ten");{</pre>
<h2>If with Else</h2>
Sometimes when the condition in an if statement evaluates to false, it would be nice to executesome code instead of the code executed when the statement evaluates to true. The "else"
________________________________________________________________________
63 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 64/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
statement effectively says that whatever code after it (whether a single line or code between brackets) is executed if the if statement is FALSE.
<pre class="example">if ( TRUE ){
// if condition is true then this block is executed}else{
// if condition is false then this block is executed}</pre>
<h2>Else If</h2>
Another use of else is when there are multiple conditional statements that may all evaluate totrue, yet you want only one if statement's body to execute. You can use an "else if" statementfollowing an if statement and its body; that way, if the first statement is true, the "else if" will beignored, but if the if statement is false, it will then check the condition for the else if statement. If the if statement was true the else statement will not be checked. It is possible to use numerouselse if statements to ensure that only one block of code is executed.
<pre class="example">if ( <condition> )
{// Execute these statements if <condition> is TRUE}else if ( <another condition> ){
// Execute these statements if <another condition> is TRUE and// <condition> is FALSE
}else{
// Execute this statements if both the above conditions evaluates to false}
</pre>
<br/>
________________________________________________________________________
64 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 65/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
<a href="index.html">HOME</a> <ahref="lesson1.html">PREVIOUS</a> <ahref="lesson3.html">NEXT</a>
</body></html>
________________________________________________________________________
65 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 66/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
OUTPUT:
________________________________________________________________________
66 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 67/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
________________________________________________________________________
67 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 68/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 02/12/2009 PRACTICAL NO.9
AIM: Develop a simple website using WML
DESCRIPTION:
Using WML
WML stands for web site meta language. This means that WML takes input .wml files, processes whatever is inside them (it can be anything from basic HTML to Perl code!), andoutputs whatever you want it to output, for example .html or .php.
The documentation for WML is not easy to learn from. It is actually quite complete, but untilyou begin to understand how it works (and it is quite powerful) it is easiest to learn from
examples. You may find template files used for the Debian site useful. They can be found inwebwml/english/template/debian/.
This assumes that you have WML installed on your machine. WML is available as a Debian package.
Editing WML sources
One thing all .wml files will have is one or more opening #use lines. You must not change or translate their syntax, only the quoted strings such as those after title=, which would change the<title> element in the output files.
Other than the header lines, most of our .wml pages contain simple HTML. If you encounter tags such as <define-tag> or <: ... :>, be careful, because those delimit code that's processed byone of WML's special passes. See below for more information.
Building Debian web pages
Simply type make in webwml/<lang>. We have set up makefiles that call wml with all the rightarguments.
If you do a make install then the HTML files will be built and placed in the directory ../../www/.
Extra WML features we use
One of the features of WML that we make extensive use of is the use of Perl. Remember, theseare not dynamic pages. Perl is used at the time the HTML pages are generated to do, well,whatever you like. Two good examples of how we are using Perl in the pages is to create the
________________________________________________________________________
68 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 69/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
list of most recent news items for the main page and to generate the links to translations at theend of the page.
To rebuild the templates of our web site, wml version >= 2.0.6 is needed. To rebuild the gettexttemplates for non-English translations, mp4h >= 1.3.0 is necessary.
Specific issues with WML
Multi-byte languages may need special pre- or post-processing of the .wml files in order tohandle the character set properly. This can be done by changing the variables WMLPROLOGand WMLEPILOG in webwml/<lang>/Make.lang appropriately. Depending on how your WMLEPILOG program works, you may need to change the value of WMLOUTFILE.See the Japanese or Chinese translations for an example.
________________________________________________________________________
69 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 70/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
SOURCE CODE:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN""http://www.wapforum.org/DTD/wml_1.1.xml">
<wml><card title="Anchor Tag"><p><anchor>Next page <go href="text.wml"/></anchor></p>
</card></wml>First page
Second Page
________________________________________________________________________
70 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 71/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
________________________________________________________________________
71 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 72/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN""http://www.wapforum.org/DTD/wml_1.1.xml">
<wml><card title="Input">
<p> Name: <input name="Name" size="15"/><br/>Age: <input name="Age" size="15" format="*N"/><br/>Sex: <input name="Sex" size="15"/></p>
</card></wml>
________________________________________________________________________
72 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 73/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
<?xml version="1.0"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN""http://www.wapforum.org/DTD/wml_1.1.xml">
<wml><card><p><anchor>Go To Test<go href="text.wml"/></anchor>
</p></card>
</wml>
________________________________________________________________________
73 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 74/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
<?xml version="1.0"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN""http://www.wapforum.org/DTD/wml_1.1.xml">
<wml><card><p>
<anchor>Previous Page<go href="pre.wml"/></anchor></p></card>
</wml>
________________________________________________________________________
74 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 75/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
<?xml version="1.0"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN""http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Tutorial"><do type="accept" label="Answer"><go href="#card2"/>
</do><p><select name="name"><option value="HTML">HTML Tutorial</option><option value="XML">XML Tutorial</option><option value="WAP">WAP Tutorial</option>
</select></p></card><card id="card2" title="Answer">
<p>You selected: $(name)</p></card></wml>
________________________________________________________________________
75 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 76/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
________________________________________________________________________
76 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 77/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
After Selecting option XML and Clicking Ok
________________________________________________________________________
77 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 78/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Date: 04/12/2009 PRACTICAL NO.10
AIM: File transfer between Laptop & Mobile phone using Bluetooth
DESCRIPTION:
Bluetooth
Bluetooth is a wireless technology that allows computers, phones and other devices to talk toeach other over short distances (up to 100 meters). Bluetooth uses radio waves (in the 2.4Gigahertz range), and is designed to be a secure and inexpensive way of connecting andexchanging information between devices without wires.
You'll find Bluetooth in many of the newer mobile phones, handheld computers, laptops,
printers, handheld organisers, as well as in all sorts of products.
Uses of Bluetooth include: sending photos from your mobile, exchanging business cards, sendingvoice from a headset to a mobile phone, and real-time satellite navigation using GPS.
This page provides some basic information on what Bluetooth has to offer, plus links toBluetooth products.
There seem to be a number of security concerns about Bluetooth - should I be worried?There have been some security concerns, and you should make your own judgment on theconvenience of Bluetooth versus the risk of having someone gaining access. Here's a summary of
the scare types:
• Bluejacking - A craze in 2004, where people with Bluetooth mobiles scan for other users
with Bluetooth enabled, and beam a Contact Card containing a greeting. This is usuallyharmless, and exploits a common feature of Bluetooth - the ability to beam businesscards. You still have to accept the card.
• Calls being overheard - some Bluetooth handsets and headsets use an obvious passcode,
such as 0000, meaning that some hackers have apparently been able to hi-jack connections (to access the microphone or to eavesdrop on a call)
• Clever thieves have been known to use Bluetooth and Wi-fi checkers to see if a car's boot
or glovebox contains a Bluetooth device•
There's some clever software out there that can make use of vulnerabilities in a smallnumber of Bluetooth phones, to establish a data connection.
For most people, the likelihood of something nasty happening is pretty low, but if you want to play it safe, here are a few tips: 1) when not using Bluetooth, turn it off. 2) Set your Bluetoothmode so that it isn't discoverable. 3) Be careful of devices that may have a guessable passcode.
________________________________________________________________________
78 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 79/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
4) Be careful when setting a device to "trusted" or "authorised", as that device can then access allof your devices services, features, and potentially - data.
Instructions:
Things will Need:
• Bluetooth enabled PC
• Bluetooth enabled cell phone
Step 1
Enable Bluetooth on the PC. To enable Bluetooth on the PC visit your control panel. Weshould see an option for Bluetooth devices. Select this option and make sure the technologyis enabled. If you are installing a USB module, we should be able to plug it in and use it
right away. If not, it should come with drivers to install (insert the disc, and install thesoftware).
Step 2
Enable bluetooth on the cell phone. Each phone is different, but you should be able to go toa settings menu, and select bluetooth. There should be an option to enable bluetooth on the phone. Enable it, and make sure the phone is visible.
Step 3
Allow the PC to search for devices. It should find the cell phone. If not, we can trysearching for the computer with the cell phone. Many times, with the USB modules, theyhave trouble finding the cell, but the cell can find the computer. The important part is thatthe devices connect, regardless of which device finds which.
Step 4
Approve the devices to connect. Sometimes, the devices will automatically connect, and wewill be ready to go. However, if this is not the case, refer to step 5.
Step 5
Enter any necessary security codes. If you do not know these codes, try the defaults, (1234,last 4 digits of your phone number, etc.).
Step 6
________________________________________________________________________
79 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 80/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Select the files on the computer that we want, and we should be able to right click and select"send via bluetooth". Click this option, and let the files send.
OR
Another way is with windows XP and blutooth enabled mobile
a) Setup on the Device
Step 1: On the device, press Menu.
Step 2: Scroll to Connect. and press the scroll key.
Step 3: Scroll to Bluetooth and press the scroll key.
Step 4: Scroll to Bluetooth and press the scroll key till On is displayed.
Step 5: Scroll to My phone’s visibility and press the scroll key till Shown to all
is displayed.
Step 6: Scroll to My phone’s name and press the scroll key..
Step 7: Enter Nokia in the field provided and press Ok.
Step 8: Press Exit and End key to go back to main screen.
b) Setup on the Laptop
Step 1: On the laptop, click on Start.
Step 2: Select Control Panel.
Step 3: Select and click on Bluetooth Devices.
Step 4: Click on Add.. and a pop-up “Add Bluetooth Device Wizard” would displayed.
Step 5: Checked on “My device is set up and ready to be found” and press Next.
________________________________________________________________________
80 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 81/82
Wireless Technology & Mobile Computing
M.C.A – Semester V
Step 6: Select on Nokia New device and press Next.
Step 7: Checked “Let me choose my own passkey” and enter an 8 to 16 digit passkey.
Step 8: Press Next..
Step 9: On your device, “Add to My Devices?” is displayed, press Yes.
Step 10: Enter the same 8 to 16 digit passkey that you have entered previously and PressOk.
Step 11: Please wait while your laptop is installing the Bluetooth.
Step 12: Press Finish when the Completing the “Add Bluetooth Device Wizard” is
displayed.
________________________________________________________________________
81 IDOL, University of
Mumbai
7/15/2019 WT MCA Journal+Format
http://slidepdf.com/reader/full/wt-mca-journalformat 82/82