SlideShare a Scribd company logo
1 of 28
Download to read offline
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
1. Program for implementing a stack & to perform Push & Pop
operations
import java.io.*;
class st
{
int top=0;
int max=0,i=0,n=0;
int stk[];
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
st()
{
try{
System.out.println("Enter the size of the stack");
max=Integer.parseInt(input.readLine());
}
catch(IOException e){}
stk=new int[max];
}
public void add()
{
try{
if(top<max)
{
System.out.println("Enter the element of the stack");
stk[top++]=Integer.parseInt(input.readLine());
}
else
System.out.println("Stack overflow");
}
catch(IOException e){}
}
public void delete()
{
if(top>0)
System.out.println("Deleted element is"+stk[--top]);
else
System.out.println("Stack underflow");
}
public void display()
{ if(top==0)
System.out.println("Stack is empty");
else
{
for(int i=0;i<top;i++)
System.out.println(" elements are"+stk[i]);
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
}
}
}
class Stack
{
public static void main(String args[])throws IOException
{
String data;
int ch=0;
st a=new st();
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
while(true)
{
System.out.println("1:PUSH 2:POP 3:DISPLAY 4:EXIT");
System.out.println("Enter ur choice");
try{
ch=Integer.parseInt(input.readLine());
}
catch(IOException e){}
switch(ch)
{
case 1:a.add();
break;
case 2:a.delete();
break;
case 3:a.display();
break;
case 4:System.exit(0);
}
}
}
}
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Output:
C:cd jdk1.3bin>javac Stack.java
C:JDK1.3BIN>java Stack
Enter the size of the stack
2
1:PUSH 2:POP 3:DISPLAY 4:EXIT
Enter ur choice
1
Enter the element of the stack
23
1:PUSH 2:POP 3:DISPLAY 4:EXIT
Enter ur choice
1
45
1:PUSH 2:POP 3:DISPLAY 4:EXIT
Enter ur choice
3
elements are 23
elements are 45
1:PUSH 2:POP 3:DISPLAY 4:EXIT
Enter ur choice
2
Deleted element is 45
1:PUSH 2:POP 3:DISPLAY 4:EXIT
Enter ur choice
4
C:JDK1.3BIN>
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
2. Program to implement the following operations on a Queue
Add an element
Delete an element
Display the elements
import java.io.*;
class Queue1
{
public static void main(String[] args)throws IOException
{
int a[]=new int [10];
int pos=0,n=0,j;
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
while(true)
{
System.out.println("1.INSERTION");
System.out.println("2.DELETION");
System.out.println("3.DISPLAY");
System.out.println("4.EXIT");
System.out.println("enter your choice");
String choice = b.readLine();
if(choice.equals("1"))
{
System.out.println("enter the element");
String ma = b.readLine();
int d = Integer.parseInt(ma);
a[pos]=d;
pos++;
n++;
}
else
if(choice.equals("2"))
{
for(j=0;j<=pos-1;j++)
a[j]=a[j+1];
pos--;
n--;
}
else
if(choice.equals("3"))
{
if(n==0)
System.out.println("QUEUE EMPTY");
else
for(j=0;j<pos;j++)
System.out.println("Elements are:t" +a[j]);
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
}
else
if(choice.equals("4"))
{
System.exit(0);
}
else
{
System.out.println("Enter proper choice");
}
}
}
}
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Output:
C:JDK1.3BIN>java Queue1
1.INSERTION
2.DELETION
3.DISPLAY
4.EXIT
Enter your choice
1
Enter the element
2
1.INSERTION
2.DELETION
3.DISPLAY
4.EXIT
Enter your choice
1
Enter the element
5
1.INSERTION
2.DELETION
3.DISPLAY
4.EXIT
Enter your choice
3
Elements are: 2
Elements are:5
1.INSERTION
2.DELETION
3.DISPLAY
4.EXIT
Enter your choice
2
1.INSERTION
2.DELETION
3.DISPLAY
4.EXIT
Enter your choice
3
Elements are: 5
1.INSERTION
2.DELETION
3.DISPLAY
4.EXIT
Enter your choice
4
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
3. Program to implement the following operations on a singly linked list
Create a List
Add a Node to the Front of the List
Add a Node to the Back of the List
Delete a Specified Node
Display a List
import java.io.*;
import java.util.*;
class Link1
{
LinkedList l1=new LinkedList();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String input;
public void create(int size)throws IOException
{
for(int i=0;i<size;i++)
{
System.out.println("Enter the node item:");
input=br.readLine();
l1.add(input);
}
}
public void last()throws IOException
{
System.out.println("Enter the item to be inserted at the last:");
input=br.readLine();
l1.addLast(input);
}
public void begin()throws IOException
{
System.out.println("Enter the item to be inserted at the begining:");
input=br.readLine();
l1.addFirst(input);
}
public void delete()throws IOException
{
int pos;
System.out.println("Enter the position:");
input=br.readLine();
pos=Integer.parseInt(input);
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
l1.remove(pos);
}
public void display()
{
System.out.println("Elements in the list:");
System.out.println(l1);
}
}
class Link14
{
public static void main(String arg[])throws IOException
{
int choice;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Link1 l=new Link1();
while(true)
{
System.out.println("1.CREATE LINKED LIST");
System.out.println("2.ADD FIRST");
System.out.println("3.ADD LAST");
System.out.println("4.REMOVE");
System.out.println("5.DISPLAY");
System.out.println("6.EXIT");
System.out.println("Enter your choice:");
choice=Integer.parseInt(br.readLine());
switch(choice)
{
case 1:System.out.println("Enter the size:");
int s=Integer.parseInt(br.readLine());
l.create(s);
break;
case 2:l.begin();
break;
case 3:l.last();
break;
case 4:l.delete();
break;
case 5:l.display();
break;
case 6:System.exit(0);
default:System.out.println("Enter Proper Choice");
}
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
}
}
}
Output:
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
C:JDK1.3BIN>java Link14
1.CREATE LINKED LIST
2.ADD FIRST
3.ADD LAST
4.REMOVE
5.DISPLAY
6.EXIT
Enter your choice:
1
Enter the size:
2
Enter the node item:
4
Enter the node item:
-2
1.CREATE LINKED LIST
2.ADD FIRST
3.ADD LAST
4.REMOVE
5.DISPLAY
6.EXIT
Enter your choice:
2
Enter the item to be inserted at the beginning:
90
1.CREATE LINKED LIST
2.ADD FIRST
3.ADD LAST
4.REMOVE
5.DISPLAY
6.EXIT
Enter your choice:
5
Elements in the list:
[90, 4, -2]
1.CREATE LINKED LIST
2.ADD FIRST
3.ADD LAST
4.REMOVE
5.DISPLAY
6.EXIT
Enter your choice:
3
Enter the item to be inserted at the last:
10
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
1.CREATE LINKED LIST
2.ADD FIRST
3.ADD LAST
4.REMOVE
5.DISPLAY
6.EXIT
Enter your choice:
5
Elements in the list:
[90, 4, -2, 10]
1.CREATE LINKED LIST
2.ADD FIRST
3.ADD LAST
4.REMOVE
5.DISPLAY
6.EXIT
Enter your choice:
4
Enter the position:
2
1.CREATE LINKED LIST
2.ADD FIRST
3.ADD LAST
4.REMOVE
5.DISPLAY
6.EXIT
Enter your choice:
5
Elements in the list:
[90, 4, 10]
1.CREATE LINKED LIST
2.ADD FIRST
3 ADD LAST
4.REMOVE
5.DISPLAY
6.EXIT
Enter your choice:
6
C:JDK1.3BIN>
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
4. Program to implement a Producer and Consumer Problem using
Threads
import java.io.*;
class Q
{
int n;
boolean valueset=false;
synchronized int get()
{
if(!valueset)
try
{
wait();
}
catch (InterruptedException e1)
{
System.out.println("Thread Interrupted");
}
System.out.println("get" +n);
valueset=false;
notify();
return n;
}
synchronized void put(int n)
{
if(valueset)
try
{
wait();
}
catch (InterruptedException e2)
{
System.out.println("thread interrupted");
}
this.n=n;
valueset=true;
System.out.println("put " +n);
notify();
}
}
class Producer implements Runnable
{
Q q; Thread t;
Producer (Q q)
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
{
this.q=q;
t=new Thread(this, "Producer");
t.start();
}
public void run()
{
int i=0;
while (i<26)
{
q.put(i++);
}
}
}
class Consumer implements Runnable
{
Q q;Thread t;
Consumer (Q q)
{
this.q=q;
t=new Thread(this, "Consumer");
t.start();
}
public void run()
{
int i=0;
while(i < 26)
{
q.get();
}
}
}
class PC
{
public static void main(String args[])
{
Q q=new Q();
new Producer(q);
new Consumer(q);
System.out.println("press ctrl+c to exit");
}
}
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Output:
C:JDK1.3BIN>javac PC.java
C:JDK1.3BIN>java PC
put 0
get0
put 1
get1
put 2
get2
put 3
get3
|
|
put 24
get24
put 25
get25
press ctrl+c to exit
C:JDK1.3BIN>
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
5. Program to create an applet to scroll a text message
import java.applet.*;
import java.awt.*;
public class AB extends Applet implements Runnable
{
String str;
int x,y;
public void init()
{
str="WELCOME TO RNSIT";
x=300;
y=100;
new Thread(this).start();
}
public void run()
{
try
{
while(true)
{
x=x-10;
if(x<0)
{
x=300;
}
repaint();
Thread.sleep(100);
}
} catch(InterruptedException e1){}
}
public void paint(Graphics g)
{
for(int i=0;i<10;i++)
g.drawString(str,x,y);
}
}
AB.html
<applet code=AB width=300 height=100>
</applet>
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Output:
C:JDK1.3BIN>javac AB.java
C:JDK1.3BIN>appletviewer AB.html
Applet Viewer:AB
Applet
WELCOME TO RNSIT
Applet started.
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
6. Develop a Java program for a Client and Server Program to do the
following:
1.The client requests for a file.
2.The server sends the contents of the file requested.
3.The client receives the file and displays it.
// code for client program
import java.net.*;
import java.util.*;
import java.io.*;
public class Client
{
public static void main(String args[])
{
Socket client=null;
BufferedReader br=null;
try
{
System.out.println(args[0]+" "+ args[1]);
client=new Socket(args[0],Integer.parseInt(args[1]));
} catch(Exception e){}
BufferedReader input=null;
PrintStream output=null;
try
{
input=new BufferedReader(new InputStreamReader(client.getInputStream()));
output=new PrintStream(client.getOutputStream());
br=new BufferedReader(new InputStreamReader(System.in));
String str=input.readLine();//get the prompt from the server
System.out.println(str);//display the prompt on the client machine
String filename=br.readLine();
if(filename!=null)
output.println(filename);
String data;
while((data=input.readLine())!=null)
System.out.println(data);
client.close();
}
catch(Exception e)
{
System.out.println(e);
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
}
}
}
/* Code for Server program*/
import java.net.*;
import java.util.*;
import java.io.*;
public class Server
{
public static void main(String args[])
{
ServerSocket server=null;
try
{
server=new ServerSocket(Integer.parseInt(args[0]));
} catch(Exception e){}
while(true)
{
Socket client=null;
PrintStream output=null;
BufferedReader input=null;
try
{
client=server.accept();
} catch(Exception e){System.out.println(e);}
try
{
output=new PrintStream(client.getOutputStream());
input=new BufferedReader(new InputStreamReader(client.getInputStream())) ;
}catch(Exception e){System.out.println(e);}
//send the command Prompt to the client
output.println("ENTER THE FILE NAME>");
try
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
{
//get the file name from the client
String filename=input.readLine();
System.out.println("Client requested file:" + filename);
try
{
File f=new File(filename);
BufferedReader br=new BufferedReader(new FileReader(f));
String data;
while((data=br.readLine())!=null)
{
output.println(data);
}
}
catch(FileNotFoundException e)
{ output.println("FILE NOT FOUND");}
client.close();
}catch(Exception e){
System.out.println(e);
}
}
}
}
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Output:
C:JDK1.3BIN>javac Client.java
C:JDK1.3BIN>javac Server.java
C:JDK1.3BIN>java Server 80
/* In a new prompt*/
C:JDK1.3BIN>java Client localhost 80
Local host 80
ENTER THE FILE NAME>
Server.java /*File Serever.java is displayed */
/*In the server prompt*/
Client requested file: Server.java
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
7. Program to implement the Simple Client/Server Application using
RM
/*Interface Program */
import java.rmi.*;
public interface TimeIntf extends Remote
{
public String getTime() throws RemoteException;
public void display() throws RemoteException;
}
/*Server Program */
import java.rmi.server.*;
import java.rmi.*;
import java.net.*;
import java.util.*;
import java.text.*;
public class TimeServer extends UnicastRemoteObject implements TimeIntf
{
TimeServer() throws Exception {}
public String getTime() throws RemoteException
{
Date dd=new Date();
SimpleDateFormat sdf;
sdf=new SimpleDateFormat("hh:mm:ss");
System.out.println("date&time"+sdf.format(dd));
String tt=sdf.format(dd);
return tt;
}
public void display() throws RemoteException
{
System.out.println("Hello This Is To Demonstrate RMI ");
}
public static void main (String args[] ) throws Exception
{
TimeServer tobj=new TimeServer();
Naming.rebind("Time",tobj);
}
}
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
/*Client Program */
import java.rmi.*;
public class TimeClient
{
public static void main(String args[]) throws Exception
{
TimeIntf t;
t=(TimeIntf)Naming.lookup("Time");
System.out.println(t.getTime());
t.display();
}
}
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Output:
C:JDK1.3BIN>javac TimeIntf.java
C:JDK1.3BIN>javac TimeServer.java
C:JDK1.3BIN>javac TimeClient.java
C:JDK1.3BIN>rmic TimeServer
C:JDK1.3BIN>start rmiregistry
/*minimize the rmiregistry window & the prompt window*/
/*Open a new prompt window*/
C:JDK1.3BIN>java TimeClient
/*Using ALT+TAB switch to the other prompt window*/
C:JDK1.3BIN>java TimeServer
Java TimeSerever
date & time 02:19:09
Hello this is to demonstrate RMI
/*Open the client prompt using ALT+TAB */
date & time 02:19:12
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
8. Create a Java Servlet program to do the following:
1. To receive employee name & telephone number from the client
browser
2. To generate a response & send it to the client browser.
Create a HTML document to do the following:
1. To accept employee name & telephone number
2. To send them to Servlet
/* Servlet Program*/
import javax.servlet.*;
import java.io.*;
public class TestServlet extends GenericServlet
{
public void service(ServletRequest request, ServletResponse response)
{
try{
PrintWriter out=response.getWriter();
String name=request.getParameter("name");
String phone=request.getParameter("phone");
out.println("<html>");
out.println("<body bgcolor=pink>");
out.println("Hello" +name);
out.println("<br><br>");
out.println("Your phone number is:" +phone);
out.println("</body></html>");
}
catch(Exception e){}
}
}
/*html Program*/
<html>
<body>
<form action="/examples/servlet/TestServlet" method="post">
Enter your name:<input type="text" name="name"><br><br>
Enter your Telphone no:<input type="text" name="phone"><br><br>
<input type="submit"value="submit">
<input type="reset" value="clear">
</form>
</body>
</html>
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Output:
C:JDK1.3BIN>javac Test Servlet.java
/*Then a TestServlet.class file is created. Move this to the path below*/
C:Apache groupTomcat 4.1web appsWeb Inf  classes TestServlet.class
/*similarly move the prg11.html file to the path below*/
C:Apache groupTomcat4.1  web apps  root  prg11.html
/* Now open the web browser*/
http://127.0.0.1:8080/prg11.html
Enter your name:
Enter your Telephone no:
submit clear
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
9. /*Create a HTML page to accept one of the three colors red,green, lue
& to send this o a Servlet. Write a Java program to create Servlet to
accept the color information sent by the client ‘s HTML page & to
generate a response.*/
/*Servlet Program*/
import java.io.*;
import javax.servlet.*;
public class pgm12 extends GenericServlet
{
public void service(ServletRequest request,ServletResponse response) throws
ServletException,IOException
{
PrintWriter out=response.getWriter();
String color=request.getParameter("r1");
out.println("<html>");
out.println("<body>");
out.println("<h1>The color you have choosen is :</h1> " +color);
out.println("</body></html>");
}
}
<!_HTML program_>
<html>
<body>
<form action="examples/servlet/pgm12" method="post">
<center>
<h3> Select any one color</h3>
<input type ="radio" name="r1" value="blue"> BLUE
<input type ="radio" name="r1" value="green"> Green
<input type ="radio" name="r1" value="red"> RED
<br><br>
<input type ="submit" value ="Submit">
</center>
</form>
</body>
</html>
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Output:
Select any one color
BLUE Green RED
Submit
The color you have chosen is: BLUE
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

More Related Content

What's hot

Pattern printing programs
Pattern printing programsPattern printing programs
Pattern printing programsMukesh Tekwani
 
C# Advanced L04-Threading
C# Advanced L04-ThreadingC# Advanced L04-Threading
C# Advanced L04-ThreadingMohammad Shaker
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_netNico Ludwig
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programingwahyuseptiansyah
 
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...Mumbai B.Sc.IT Study
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL fileRACHIT_GUPTA
 
Next Generation Developer Testing: Parameterized Testing
Next Generation Developer Testing: Parameterized TestingNext Generation Developer Testing: Parameterized Testing
Next Generation Developer Testing: Parameterized TestingTao Xie
 
C# console programms
C# console programmsC# console programms
C# console programmsYasir Khan
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginnersishan0019
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3Dillon Lee
 

What's hot (19)

Code red SUM
Code red SUMCode red SUM
Code red SUM
 
Lab4
Lab4Lab4
Lab4
 
Programs of java
Programs of javaPrograms of java
Programs of java
 
C#
C#C#
C#
 
Pattern printing programs
Pattern printing programsPattern printing programs
Pattern printing programs
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
C# Advanced L04-Threading
C# Advanced L04-ThreadingC# Advanced L04-Threading
C# Advanced L04-Threading
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
 
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL file
 
Next Generation Developer Testing: Parameterized Testing
Next Generation Developer Testing: Parameterized TestingNext Generation Developer Testing: Parameterized Testing
Next Generation Developer Testing: Parameterized Testing
 
JavaExamples
JavaExamplesJavaExamples
JavaExamples
 
delegates
delegatesdelegates
delegates
 
C# console programms
C# console programmsC# console programms
C# console programms
 
Thread
ThreadThread
Thread
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginners
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 
Server1
Server1Server1
Server1
 

Viewers also liked

Pizza presentation ac
Pizza presentation acPizza presentation ac
Pizza presentation acaamcgyver3
 
Evaluation!!!!!!!!!!!!!!!!!
Evaluation!!!!!!!!!!!!!!!!!Evaluation!!!!!!!!!!!!!!!!!
Evaluation!!!!!!!!!!!!!!!!!Roxanna charlton
 
Uppf spring 2010 highlights
Uppf spring 2010 highlightsUppf spring 2010 highlights
Uppf spring 2010 highlightsjuzdeno
 
Multiplicity of themes in “Middlemarch” (A Study of Provincial Life)
Multiplicity of themes in “Middlemarch” (A Study of Provincial Life)Multiplicity of themes in “Middlemarch” (A Study of Provincial Life)
Multiplicity of themes in “Middlemarch” (A Study of Provincial Life)Siddharth Desai
 
Joleen Huertas - E-portfolio
Joleen Huertas - E-portfolioJoleen Huertas - E-portfolio
Joleen Huertas - E-portfolioJoleen Huertas
 
Guía Turística Huellas México-Viajes Mundo Maya
Guía Turística Huellas México-Viajes Mundo MayaGuía Turística Huellas México-Viajes Mundo Maya
Guía Turística Huellas México-Viajes Mundo MayaHuellas México
 
Major themes in robinson crusoe
Major themes in robinson crusoeMajor themes in robinson crusoe
Major themes in robinson crusoeSiddharth Desai
 
Ecosistemas Mobile - eCommerce Day Argentina 2016
Ecosistemas Mobile - eCommerce Day Argentina 2016Ecosistemas Mobile - eCommerce Day Argentina 2016
Ecosistemas Mobile - eCommerce Day Argentina 2016Mariano Carrizo
 
Various types of Business Letters
Various types of Business LettersVarious types of Business Letters
Various types of Business LettersSiddharth Desai
 
Practical Comparison between two Victorian Novels-“Oliver Twist” and “Middlem...
Practical Comparison between twoVictorian Novels-“Oliver Twist” and “Middlem...Practical Comparison between twoVictorian Novels-“Oliver Twist” and “Middlem...
Practical Comparison between two Victorian Novels-“Oliver Twist” and “Middlem...Siddharth Desai
 
MashupXFeed et la stratégie éditoriale - Workshop Activis - GreenIvory
MashupXFeed et la stratégie éditoriale - Workshop Activis - GreenIvoryMashupXFeed et la stratégie éditoriale - Workshop Activis - GreenIvory
MashupXFeed et la stratégie éditoriale - Workshop Activis - GreenIvoryJean-Georges Perrin
 

Viewers also liked (20)

Pizza presentation ac
Pizza presentation acPizza presentation ac
Pizza presentation ac
 
UAPR - 2007-2008
UAPR - 2007-2008UAPR - 2007-2008
UAPR - 2007-2008
 
Evaluation!!!!!!!!!!!!!!!!!
Evaluation!!!!!!!!!!!!!!!!!Evaluation!!!!!!!!!!!!!!!!!
Evaluation!!!!!!!!!!!!!!!!!
 
Uppf spring 2010 highlights
Uppf spring 2010 highlightsUppf spring 2010 highlights
Uppf spring 2010 highlights
 
Multiplicity of themes in “Middlemarch” (A Study of Provincial Life)
Multiplicity of themes in “Middlemarch” (A Study of Provincial Life)Multiplicity of themes in “Middlemarch” (A Study of Provincial Life)
Multiplicity of themes in “Middlemarch” (A Study of Provincial Life)
 
UAPR - 2009
UAPR - 2009UAPR - 2009
UAPR - 2009
 
UAPR - 2009
UAPR - 2009UAPR - 2009
UAPR - 2009
 
54240326 copy
54240326   copy54240326   copy
54240326 copy
 
Translation
TranslationTranslation
Translation
 
Joleen Huertas - E-portfolio
Joleen Huertas - E-portfolioJoleen Huertas - E-portfolio
Joleen Huertas - E-portfolio
 
Literary terms
Literary termsLiterary terms
Literary terms
 
Doctor faustus
Doctor faustusDoctor faustus
Doctor faustus
 
S A Anand_Profile
S A Anand_ProfileS A Anand_Profile
S A Anand_Profile
 
Assesment
AssesmentAssesment
Assesment
 
Guía Turística Huellas México-Viajes Mundo Maya
Guía Turística Huellas México-Viajes Mundo MayaGuía Turística Huellas México-Viajes Mundo Maya
Guía Turística Huellas México-Viajes Mundo Maya
 
Major themes in robinson crusoe
Major themes in robinson crusoeMajor themes in robinson crusoe
Major themes in robinson crusoe
 
Ecosistemas Mobile - eCommerce Day Argentina 2016
Ecosistemas Mobile - eCommerce Day Argentina 2016Ecosistemas Mobile - eCommerce Day Argentina 2016
Ecosistemas Mobile - eCommerce Day Argentina 2016
 
Various types of Business Letters
Various types of Business LettersVarious types of Business Letters
Various types of Business Letters
 
Practical Comparison between two Victorian Novels-“Oliver Twist” and “Middlem...
Practical Comparison between twoVictorian Novels-“Oliver Twist” and “Middlem...Practical Comparison between twoVictorian Novels-“Oliver Twist” and “Middlem...
Practical Comparison between two Victorian Novels-“Oliver Twist” and “Middlem...
 
MashupXFeed et la stratégie éditoriale - Workshop Activis - GreenIvory
MashupXFeed et la stratégie éditoriale - Workshop Activis - GreenIvoryMashupXFeed et la stratégie éditoriale - Workshop Activis - GreenIvory
MashupXFeed et la stratégie éditoriale - Workshop Activis - GreenIvory
 

Similar to 54240326 (1)

Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntuKhurshid Asghar
 
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfkostikjaylonshaewe47
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfoptokunal1
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Java Programs Lab File
Java Programs Lab FileJava Programs Lab File
Java Programs Lab FileKandarp Tiwari
 
java slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfjava slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfkokah57440
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
Modify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdfModify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdfsaxenaavnish1
 
(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manualChandrapriya Jayabal
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streamsShahjahan Samoon
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdfinfo30292
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdfakkhan101
 
Java interface and inheritance
Java interface and inheritanceJava interface and inheritance
Java interface and inheritanceJaromirJagr
 

Similar to 54240326 (1) (20)

Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntu
 
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
 
Java programs
Java programsJava programs
Java programs
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
 
Inheritance
InheritanceInheritance
Inheritance
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
Bhaloo
BhalooBhaloo
Bhaloo
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Java Programs Lab File
Java Programs Lab FileJava Programs Lab File
Java Programs Lab File
 
java slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfjava slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdf
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Modify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdfModify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdf
 
(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual
 
Java ppt
Java pptJava ppt
Java ppt
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
Java interface and inheritance
Java interface and inheritanceJava interface and inheritance
Java interface and inheritance
 

54240326 (1)

  • 1. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 1. Program for implementing a stack & to perform Push & Pop operations import java.io.*; class st { int top=0; int max=0,i=0,n=0; int stk[]; BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); st() { try{ System.out.println("Enter the size of the stack"); max=Integer.parseInt(input.readLine()); } catch(IOException e){} stk=new int[max]; } public void add() { try{ if(top<max) { System.out.println("Enter the element of the stack"); stk[top++]=Integer.parseInt(input.readLine()); } else System.out.println("Stack overflow"); } catch(IOException e){} } public void delete() { if(top>0) System.out.println("Deleted element is"+stk[--top]); else System.out.println("Stack underflow"); } public void display() { if(top==0) System.out.println("Stack is empty"); else { for(int i=0;i<top;i++) System.out.println(" elements are"+stk[i]);
  • 2. Downloaded from www.pencilji.com Downloaded from www.pencilji.com } } } class Stack { public static void main(String args[])throws IOException { String data; int ch=0; st a=new st(); BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); while(true) { System.out.println("1:PUSH 2:POP 3:DISPLAY 4:EXIT"); System.out.println("Enter ur choice"); try{ ch=Integer.parseInt(input.readLine()); } catch(IOException e){} switch(ch) { case 1:a.add(); break; case 2:a.delete(); break; case 3:a.display(); break; case 4:System.exit(0); } } } }
  • 3. Downloaded from www.pencilji.com Downloaded from www.pencilji.com Output: C:cd jdk1.3bin>javac Stack.java C:JDK1.3BIN>java Stack Enter the size of the stack 2 1:PUSH 2:POP 3:DISPLAY 4:EXIT Enter ur choice 1 Enter the element of the stack 23 1:PUSH 2:POP 3:DISPLAY 4:EXIT Enter ur choice 1 45 1:PUSH 2:POP 3:DISPLAY 4:EXIT Enter ur choice 3 elements are 23 elements are 45 1:PUSH 2:POP 3:DISPLAY 4:EXIT Enter ur choice 2 Deleted element is 45 1:PUSH 2:POP 3:DISPLAY 4:EXIT Enter ur choice 4 C:JDK1.3BIN>
  • 4. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 2. Program to implement the following operations on a Queue Add an element Delete an element Display the elements import java.io.*; class Queue1 { public static void main(String[] args)throws IOException { int a[]=new int [10]; int pos=0,n=0,j; BufferedReader b=new BufferedReader(new InputStreamReader(System.in)); while(true) { System.out.println("1.INSERTION"); System.out.println("2.DELETION"); System.out.println("3.DISPLAY"); System.out.println("4.EXIT"); System.out.println("enter your choice"); String choice = b.readLine(); if(choice.equals("1")) { System.out.println("enter the element"); String ma = b.readLine(); int d = Integer.parseInt(ma); a[pos]=d; pos++; n++; } else if(choice.equals("2")) { for(j=0;j<=pos-1;j++) a[j]=a[j+1]; pos--; n--; } else if(choice.equals("3")) { if(n==0) System.out.println("QUEUE EMPTY"); else for(j=0;j<pos;j++) System.out.println("Elements are:t" +a[j]);
  • 5. Downloaded from www.pencilji.com Downloaded from www.pencilji.com } else if(choice.equals("4")) { System.exit(0); } else { System.out.println("Enter proper choice"); } } } }
  • 6. Downloaded from www.pencilji.com Downloaded from www.pencilji.com Output: C:JDK1.3BIN>java Queue1 1.INSERTION 2.DELETION 3.DISPLAY 4.EXIT Enter your choice 1 Enter the element 2 1.INSERTION 2.DELETION 3.DISPLAY 4.EXIT Enter your choice 1 Enter the element 5 1.INSERTION 2.DELETION 3.DISPLAY 4.EXIT Enter your choice 3 Elements are: 2 Elements are:5 1.INSERTION 2.DELETION 3.DISPLAY 4.EXIT Enter your choice 2 1.INSERTION 2.DELETION 3.DISPLAY 4.EXIT Enter your choice 3 Elements are: 5 1.INSERTION 2.DELETION 3.DISPLAY 4.EXIT Enter your choice 4
  • 7. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 3. Program to implement the following operations on a singly linked list Create a List Add a Node to the Front of the List Add a Node to the Back of the List Delete a Specified Node Display a List import java.io.*; import java.util.*; class Link1 { LinkedList l1=new LinkedList(); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String input; public void create(int size)throws IOException { for(int i=0;i<size;i++) { System.out.println("Enter the node item:"); input=br.readLine(); l1.add(input); } } public void last()throws IOException { System.out.println("Enter the item to be inserted at the last:"); input=br.readLine(); l1.addLast(input); } public void begin()throws IOException { System.out.println("Enter the item to be inserted at the begining:"); input=br.readLine(); l1.addFirst(input); } public void delete()throws IOException { int pos; System.out.println("Enter the position:"); input=br.readLine(); pos=Integer.parseInt(input);
  • 8. Downloaded from www.pencilji.com Downloaded from www.pencilji.com l1.remove(pos); } public void display() { System.out.println("Elements in the list:"); System.out.println(l1); } } class Link14 { public static void main(String arg[])throws IOException { int choice; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); Link1 l=new Link1(); while(true) { System.out.println("1.CREATE LINKED LIST"); System.out.println("2.ADD FIRST"); System.out.println("3.ADD LAST"); System.out.println("4.REMOVE"); System.out.println("5.DISPLAY"); System.out.println("6.EXIT"); System.out.println("Enter your choice:"); choice=Integer.parseInt(br.readLine()); switch(choice) { case 1:System.out.println("Enter the size:"); int s=Integer.parseInt(br.readLine()); l.create(s); break; case 2:l.begin(); break; case 3:l.last(); break; case 4:l.delete(); break; case 5:l.display(); break; case 6:System.exit(0); default:System.out.println("Enter Proper Choice"); }
  • 9. Downloaded from www.pencilji.com Downloaded from www.pencilji.com } } } Output:
  • 10. Downloaded from www.pencilji.com Downloaded from www.pencilji.com C:JDK1.3BIN>java Link14 1.CREATE LINKED LIST 2.ADD FIRST 3.ADD LAST 4.REMOVE 5.DISPLAY 6.EXIT Enter your choice: 1 Enter the size: 2 Enter the node item: 4 Enter the node item: -2 1.CREATE LINKED LIST 2.ADD FIRST 3.ADD LAST 4.REMOVE 5.DISPLAY 6.EXIT Enter your choice: 2 Enter the item to be inserted at the beginning: 90 1.CREATE LINKED LIST 2.ADD FIRST 3.ADD LAST 4.REMOVE 5.DISPLAY 6.EXIT Enter your choice: 5 Elements in the list: [90, 4, -2] 1.CREATE LINKED LIST 2.ADD FIRST 3.ADD LAST 4.REMOVE 5.DISPLAY 6.EXIT Enter your choice: 3 Enter the item to be inserted at the last: 10
  • 11. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 1.CREATE LINKED LIST 2.ADD FIRST 3.ADD LAST 4.REMOVE 5.DISPLAY 6.EXIT Enter your choice: 5 Elements in the list: [90, 4, -2, 10] 1.CREATE LINKED LIST 2.ADD FIRST 3.ADD LAST 4.REMOVE 5.DISPLAY 6.EXIT Enter your choice: 4 Enter the position: 2 1.CREATE LINKED LIST 2.ADD FIRST 3.ADD LAST 4.REMOVE 5.DISPLAY 6.EXIT Enter your choice: 5 Elements in the list: [90, 4, 10] 1.CREATE LINKED LIST 2.ADD FIRST 3 ADD LAST 4.REMOVE 5.DISPLAY 6.EXIT Enter your choice: 6 C:JDK1.3BIN>
  • 12. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 4. Program to implement a Producer and Consumer Problem using Threads import java.io.*; class Q { int n; boolean valueset=false; synchronized int get() { if(!valueset) try { wait(); } catch (InterruptedException e1) { System.out.println("Thread Interrupted"); } System.out.println("get" +n); valueset=false; notify(); return n; } synchronized void put(int n) { if(valueset) try { wait(); } catch (InterruptedException e2) { System.out.println("thread interrupted"); } this.n=n; valueset=true; System.out.println("put " +n); notify(); } } class Producer implements Runnable { Q q; Thread t; Producer (Q q)
  • 13. Downloaded from www.pencilji.com Downloaded from www.pencilji.com { this.q=q; t=new Thread(this, "Producer"); t.start(); } public void run() { int i=0; while (i<26) { q.put(i++); } } } class Consumer implements Runnable { Q q;Thread t; Consumer (Q q) { this.q=q; t=new Thread(this, "Consumer"); t.start(); } public void run() { int i=0; while(i < 26) { q.get(); } } } class PC { public static void main(String args[]) { Q q=new Q(); new Producer(q); new Consumer(q); System.out.println("press ctrl+c to exit"); } }
  • 14. Downloaded from www.pencilji.com Downloaded from www.pencilji.com Output: C:JDK1.3BIN>javac PC.java C:JDK1.3BIN>java PC put 0 get0 put 1 get1 put 2 get2 put 3 get3 | | put 24 get24 put 25 get25 press ctrl+c to exit C:JDK1.3BIN>
  • 15. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 5. Program to create an applet to scroll a text message import java.applet.*; import java.awt.*; public class AB extends Applet implements Runnable { String str; int x,y; public void init() { str="WELCOME TO RNSIT"; x=300; y=100; new Thread(this).start(); } public void run() { try { while(true) { x=x-10; if(x<0) { x=300; } repaint(); Thread.sleep(100); } } catch(InterruptedException e1){} } public void paint(Graphics g) { for(int i=0;i<10;i++) g.drawString(str,x,y); } } AB.html <applet code=AB width=300 height=100> </applet>
  • 16. Downloaded from www.pencilji.com Downloaded from www.pencilji.com Output: C:JDK1.3BIN>javac AB.java C:JDK1.3BIN>appletviewer AB.html Applet Viewer:AB Applet WELCOME TO RNSIT Applet started.
  • 17. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 6. Develop a Java program for a Client and Server Program to do the following: 1.The client requests for a file. 2.The server sends the contents of the file requested. 3.The client receives the file and displays it. // code for client program import java.net.*; import java.util.*; import java.io.*; public class Client { public static void main(String args[]) { Socket client=null; BufferedReader br=null; try { System.out.println(args[0]+" "+ args[1]); client=new Socket(args[0],Integer.parseInt(args[1])); } catch(Exception e){} BufferedReader input=null; PrintStream output=null; try { input=new BufferedReader(new InputStreamReader(client.getInputStream())); output=new PrintStream(client.getOutputStream()); br=new BufferedReader(new InputStreamReader(System.in)); String str=input.readLine();//get the prompt from the server System.out.println(str);//display the prompt on the client machine String filename=br.readLine(); if(filename!=null) output.println(filename); String data; while((data=input.readLine())!=null) System.out.println(data); client.close(); } catch(Exception e) { System.out.println(e);
  • 18. Downloaded from www.pencilji.com Downloaded from www.pencilji.com } } } /* Code for Server program*/ import java.net.*; import java.util.*; import java.io.*; public class Server { public static void main(String args[]) { ServerSocket server=null; try { server=new ServerSocket(Integer.parseInt(args[0])); } catch(Exception e){} while(true) { Socket client=null; PrintStream output=null; BufferedReader input=null; try { client=server.accept(); } catch(Exception e){System.out.println(e);} try { output=new PrintStream(client.getOutputStream()); input=new BufferedReader(new InputStreamReader(client.getInputStream())) ; }catch(Exception e){System.out.println(e);} //send the command Prompt to the client output.println("ENTER THE FILE NAME>"); try
  • 19. Downloaded from www.pencilji.com Downloaded from www.pencilji.com { //get the file name from the client String filename=input.readLine(); System.out.println("Client requested file:" + filename); try { File f=new File(filename); BufferedReader br=new BufferedReader(new FileReader(f)); String data; while((data=br.readLine())!=null) { output.println(data); } } catch(FileNotFoundException e) { output.println("FILE NOT FOUND");} client.close(); }catch(Exception e){ System.out.println(e); } } } }
  • 20. Downloaded from www.pencilji.com Downloaded from www.pencilji.com Output: C:JDK1.3BIN>javac Client.java C:JDK1.3BIN>javac Server.java C:JDK1.3BIN>java Server 80 /* In a new prompt*/ C:JDK1.3BIN>java Client localhost 80 Local host 80 ENTER THE FILE NAME> Server.java /*File Serever.java is displayed */ /*In the server prompt*/ Client requested file: Server.java
  • 21. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 7. Program to implement the Simple Client/Server Application using RM /*Interface Program */ import java.rmi.*; public interface TimeIntf extends Remote { public String getTime() throws RemoteException; public void display() throws RemoteException; } /*Server Program */ import java.rmi.server.*; import java.rmi.*; import java.net.*; import java.util.*; import java.text.*; public class TimeServer extends UnicastRemoteObject implements TimeIntf { TimeServer() throws Exception {} public String getTime() throws RemoteException { Date dd=new Date(); SimpleDateFormat sdf; sdf=new SimpleDateFormat("hh:mm:ss"); System.out.println("date&time"+sdf.format(dd)); String tt=sdf.format(dd); return tt; } public void display() throws RemoteException { System.out.println("Hello This Is To Demonstrate RMI "); } public static void main (String args[] ) throws Exception { TimeServer tobj=new TimeServer(); Naming.rebind("Time",tobj); } }
  • 22. Downloaded from www.pencilji.com Downloaded from www.pencilji.com /*Client Program */ import java.rmi.*; public class TimeClient { public static void main(String args[]) throws Exception { TimeIntf t; t=(TimeIntf)Naming.lookup("Time"); System.out.println(t.getTime()); t.display(); } }
  • 23. Downloaded from www.pencilji.com Downloaded from www.pencilji.com Output: C:JDK1.3BIN>javac TimeIntf.java C:JDK1.3BIN>javac TimeServer.java C:JDK1.3BIN>javac TimeClient.java C:JDK1.3BIN>rmic TimeServer C:JDK1.3BIN>start rmiregistry /*minimize the rmiregistry window & the prompt window*/ /*Open a new prompt window*/ C:JDK1.3BIN>java TimeClient /*Using ALT+TAB switch to the other prompt window*/ C:JDK1.3BIN>java TimeServer Java TimeSerever date & time 02:19:09 Hello this is to demonstrate RMI /*Open the client prompt using ALT+TAB */ date & time 02:19:12
  • 24. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 8. Create a Java Servlet program to do the following: 1. To receive employee name & telephone number from the client browser 2. To generate a response & send it to the client browser. Create a HTML document to do the following: 1. To accept employee name & telephone number 2. To send them to Servlet /* Servlet Program*/ import javax.servlet.*; import java.io.*; public class TestServlet extends GenericServlet { public void service(ServletRequest request, ServletResponse response) { try{ PrintWriter out=response.getWriter(); String name=request.getParameter("name"); String phone=request.getParameter("phone"); out.println("<html>"); out.println("<body bgcolor=pink>"); out.println("Hello" +name); out.println("<br><br>"); out.println("Your phone number is:" +phone); out.println("</body></html>"); } catch(Exception e){} } } /*html Program*/ <html> <body> <form action="/examples/servlet/TestServlet" method="post"> Enter your name:<input type="text" name="name"><br><br> Enter your Telphone no:<input type="text" name="phone"><br><br> <input type="submit"value="submit"> <input type="reset" value="clear"> </form> </body> </html>
  • 25. Downloaded from www.pencilji.com Downloaded from www.pencilji.com Output: C:JDK1.3BIN>javac Test Servlet.java /*Then a TestServlet.class file is created. Move this to the path below*/ C:Apache groupTomcat 4.1web appsWeb Inf classes TestServlet.class /*similarly move the prg11.html file to the path below*/ C:Apache groupTomcat4.1 web apps root prg11.html /* Now open the web browser*/ http://127.0.0.1:8080/prg11.html Enter your name: Enter your Telephone no: submit clear
  • 26. Downloaded from www.pencilji.com Downloaded from www.pencilji.com 9. /*Create a HTML page to accept one of the three colors red,green, lue & to send this o a Servlet. Write a Java program to create Servlet to accept the color information sent by the client ‘s HTML page & to generate a response.*/ /*Servlet Program*/ import java.io.*; import javax.servlet.*; public class pgm12 extends GenericServlet { public void service(ServletRequest request,ServletResponse response) throws ServletException,IOException { PrintWriter out=response.getWriter(); String color=request.getParameter("r1"); out.println("<html>"); out.println("<body>"); out.println("<h1>The color you have choosen is :</h1> " +color); out.println("</body></html>"); } } <!_HTML program_> <html> <body> <form action="examples/servlet/pgm12" method="post"> <center> <h3> Select any one color</h3> <input type ="radio" name="r1" value="blue"> BLUE <input type ="radio" name="r1" value="green"> Green <input type ="radio" name="r1" value="red"> RED <br><br> <input type ="submit" value ="Submit"> </center> </form> </body> </html>
  • 27. Downloaded from www.pencilji.com Downloaded from www.pencilji.com Output: Select any one color BLUE Green RED Submit The color you have chosen is: BLUE