EX.

NO:1(A) DATE:11/07/2012

SIMPLE JAVA PROGRAM

AIM: To write a simple java program to display the required data.

ALGORITHM: 1. 2. 3. 4. Create a class named sample. Write the code to display the content “JAVA LAB”. Save the program. Compile and display the result.

PROGRAM: import java.io.*; class sample { public static void main(String s[]) { System.out.println("JAVA LAB"); } }

OUTPUT:

.RESULT: Thus a sample java program to display the required data was executed.

5. Compile and display the results. Create a class object using this object specify values for the integer. . ALGORITHM: 1. 2. 4. 3. Create another class which is the main class. Create a method to return the sum of the values.EX:NO:1(B) AIM: SIMPLE JAVA PROGRAM USING TWO CLASSES To write a simple java program using two classes to find the sum of the given values. Using the object call the method to display the sum of the three integer. Create a class with three integer values. 6.

io.m=70.*.l=60. obj. class a { int l. int tot() { return l+m+n.n=50.out. obj. obj. ans=obj.PROGRAM: import java.} } .m.println("The total is: "+ans).n. System.tot(). a obj=new a().}} class bb { public static void main(String args[]) { int ans.

OUTPUT: .

RESULT: Thus the sample java program using two classes to find sum of the given values was executed. .

Create the class with class name. 2. 3. Compute and run the program to display the result. ALGORITHM: 1. To create the package and subpackage from the utility function in java. . Get the input data using the string function. 4. Create the object for a class and call the object to display the date and time. 5.EX:NO:1(C) AIM: TO DISPLAY DATE AND TIME To write the java program to display current date and time.

text.SimpleDateFormat.out.Calendar. public class GetDateNow { public static void main(String arg[]) { Calendar Date=Calendar.println("Now the date is:--> "+DateNow). System.PROGRAM: import java. String DateNow=formatter.format(Date. } } . SimpleDateFormat formatter=new SimpleDateFormat("yyyy/mm/dd hh:mm:ss").util.getTime()).getInstance(). import java.

OUTPUT: .

RESULT: Thus the Java program to display the current date and time was written and executed. .

Initialise variable l1. 2.NO:02 DATE:12/07/2012 EVENT HANDLING MECHANISM AIM: To write a java program for the event handling mechanism. The Label of „Submit‟ button is obtained y calling the getAction command() method on the ActionEvent object passed to action Performed(). If „submit‟ button is pressed contents of tf1 and tf2 are concatenated and are displayed on the window. Create an object bh for class ButtonHandler. Create a subclass „test‟ inherited from superclass Applet.tf1.l2. ALGORITHM: 1.ta and b1. . Using add() method labels. ActionEvent object is passed as a reference to string „s‟.button. 9.textfield tf1. Generate a window which can be viewed with an applet viewer. 7. Declare label l1. 6.textarea ta. 8.textfield and textarea are added to the window. 5.l2.button b1.EX.tf2. 3.tf2. 4.

l2. add(tf2).setText(tf1. } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent ae) { String s=ae. add(ta). public void init() { l1=new Label("Text 1"). ButtonHandler bh=new ButtonHandler(). add(tf1). add(b1). import java.equals("Submit")) { ta. Button b1.PROGRAM: import java.event. if(s.*.getText()+tf2. TextArea ta. ta=new TextArea(10.awt.20). TextField tf1. add(l2).*.io. }}}} .tf2.awt.getText()). import java.*. b1.addActionListener(bh).getActionCommand(). import java.*. b1=new Button("Submit"). add(l1).applet. tf2=new TextField(20). tf1=new TextField(20). l2=new Label("Text 2"). public class Event extends Applet { Label l1.

OUTPUT: .

.RESULT: Thus the program for event handling mechanism has been written and executed.

BufferedWriter is used to buffered output character stream. write a file and copy a file using java. Compile and save it. 6.NO:03 DATE:25/07/2012 FILE HANDLING AIM: To create a file. Else create a file to the current directory by exception. 6.EX. Open the file first that is required to read. 7. 3. Use BufferedReader for Buffered Input character. Print the content on the console or display. BufferedReader is used for the Buffered Input character condition stream. Assign the file name to the variable f. Close the output stream. 2. Get the object of DataInputStream. Create a class named createfile. Create a class named fileread. 2. WRITE A FILE: 1. . Create a class named filewriter. 4. 2. 5. Declare a variable f for the file. Close the input stream. read a file. 5. 3. ALGORITHM : CREATE A FILE: 1. If file already exists print „File already exists‟. If not exists create a new file using Boolean. 5. READ A FILE: 1. Enter the file name to create. 4. 6. 4. Read the file line by line using while loop condition. 3.

7. 2. if file not found throws the exception and exit. 6. Using switch case statement. . Create a class name copyfile. Using exception handling.COPY A FILE 1. 3. Close the input stream and output stream. 5. Display file copied. Write the contents in the file. Catch the exception and display that get message. 4. 8. Open the input stream and output stream for copying the file. Mention the length of the stream using by bytelen. to copy the contents of file1 to file2 and also give the default condition. 9.

PROGRAM: CREATE A FILE import java. f=new File("myfile.io.out.*.*. class FileRead { public static void main(String args[]) { try { FileInputStream fstream=new FileInputStream("textfile.io.out.close(). if(!f.println(strLine). public class CreateFile1 public static void main(String []args)throws IOException { File f. public class FileWrite { .*. BufferedReader br=new BufferedReader(new InputStreamReader(in)).io.println("Newfile\"myfile.err. while((strLine=br. }} READ A FILE import java. }}} WRITE A FILE: import java.println("Error:"+e. DataInputStream in=new DataInputStream(fstream). } else System.createNewFile().readLine())!=null) { System.println("The specified file is already exist").txt\"has been created to the current directory").getMessage()). } in.txt"). } catch(Exception e) { System. System.out.exists()) { f. String strLine.txt").

write(in. } else { FileWriter fstream=new FileWriter(file_name).read(buf))>0) { out. System.String dtFile) { try { File f1=new File(srFile).out. OutputStream out=new FileOutputStream(f2.readLine()).println("File created Successfully"). }}} COPY A FILE: import java. out.out.public static void main(String []args)throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System. System.write(buf.true). String file_name=in. InputStream in=new FileInputStream(f1). System. OutputStream ut=new FileOutputStream(f2). File file=new File(file_name). out.readLine(). while((len=in.close().len).close().createNewFile().*. public class CopyFile { private static void copyfile(String srFile. } catch(FileNotFoundException ex) .out. int len.exit(0).println("File already exists"). File f2=new File(dtFile). if(!exist) { System.0.println("File copied"). BufferedWriter out=new BufferedWriter(fstream).println("please enter the file name to create").io. boolean exist=file. System. byte[] buf=new byte[1024]. } in. out.out.in)).close().

System.exit(0). default: System. } catch(IOException e) { System.exit(0). case 2:copyfile(args[0]. System. case 1:System.exit(0). } } } . } } public static void main(String []args) { switch(args.exit(0).getMessage()).println("Multiple files are not allow").out.println(e.{ System.out.getMessage()+"in the specified directory").println("File has not mentioned"). System.exit(0). System.out.out. System.length) { case 0:System.println("Destination file has not mentioned").println(ex.args[1]).out.

OUTPUT: CREATE A FILE: READ A FILE: .

WRITE A FILE: COPY A FILE: .

read a file. . write a file and copy a file was written and executed.RESULT: Thus the program to create a file.

3. Create an variable for print stream as os. 5. 6. . 2. Declare an object for socket as s and declare it as null. Create the object for os.is.Display the exception if caught.is1 and os. Output stream also created and declare it as null. 8. 7.is1 in try block. 5. Create the variables for input stream is and is1 and declare it as null. 7. Close the input and output stream. Display the exception if caught.EX. 9. 10. create the object for is. Create the class TCPclient1. Declare an object for socket as c and declare it as null. 9. Catch the exception e. 6. 4. 10. Give the address for the socket of server. 8. In the try block. 4. Give the IP address for client c. Using do while condition read the line by line of the content and then close the is and os. 2. Catch the exception e. Create a class TCPserver1. ALGORITHM: SERVER APPLICATION: 1. Create the two variables is. CLIENT APPLICATION: 1.is1 and declare it as null. 3.NO:04 DATE:01/08/2012 (a) CLIENT SERVER APPLICATION FOR CHAT USING TCP AIM: To chat with client and server application using TCP/IP protocols. Using do while condition read the content line by line.

*. os.java import java.getInputStream()). is1=new DataInputStream(System.out.io.out.equalsIgnoreCase("quit")==false).in).out. } catch(IOException e) { System.out. Socket c=null. System. import java.println(Line).readLine().accept(). PrintStream os=null.println("client"+Line). os=new PrintStream(c.is1=null.*.PROGRAM: TCPserver1. String Line.readLine(). } try { c=s. try { s=new ServerSocket(9999).getOutputStream()). System. public class TCPserver1 { public static void main(String arg[]) { ServerSocket s=null. } while(Line. do { Line=is. os. }}} .close(). DataInputStream is=null.println(e).println(e). is.net. Line=is1.println("Server").close(). is=new DataInputStream(c. } catch(IOException e) { System.

do { System.is1.*.java import java.0. is1.out. }}} . is=new DataInputStream(System.getInputStream()).io. os. String Line. System.readLine().in). } catch(IOException e) { System. os. PrintStream os.out.getOutputStream()).0.println("socket closed! Message is passing over").close().close(). Line=is.TCPclient1. } try { os=new PrintStream(c. is1=new DataInputStream(c. DataInputStream is.println(e).*. import java.net.9999). } catch(IOException e) { System.println(Line).out.equalsIgnoreCase("quit")==false). try { c=new Socket("127.println("client").out. } while(Line.println("server"+is1.1". public class TCPclient1 { public static void main(String args[]) { Socket c=null.readLine()).

C:\Program Files\Java\jdk1.5.java uses or overrides a deprecated API.5. Note: Recompile with -deprecation for details. Note: Recompile with -deprecation for details.OUTPUT: Server C:\Program Files\Java\jdk1.0\bin>java TCPserver1 Client: Hai Server Server: Hai Client Client: How are you Server: Fine Client: quit Server: quit Client C:\Program Files\Java\jdk1. C:\Program Files\Java\jdk1.java Note: TCPclient1.5.0\bin>java TCPclient1 Client: Hai Server Server: Hai Client Client: How are you Server: Fine Client: quit .java Note: TCPserver1.java uses or overrides a deprecated API.0\bin>javac TCPserver1.0\bin>javac TCPclient1.5.

RESULT: Thus the program Using TCP by client server application for chat written and executed successfully. .

read the content line by line.EX. Create an object for output stream os and input stream is. 5. CLIENT APPLICATION: 1. Display the exception if caught.is1 and printstream os. Using while read the content line by line. Display the message socket closed. 9. 3. 5. Create the class EServer. 3.is for print and input stream. Create an object c for client socket and declare it as null. Display the exception if caught. Create an object for input stream is. Give the IP address for the client. 9. 2.NO:04(b) AIM: IMPLEMENTATION OF TCP/IP ECHO To implement TCP/IP Echo application. Create an object ps. 2. Create an object s for socket of server and declare it as null. Create an object for input stream and print stream in try. ALGORITHM: SERVER APLLICATION: 1. Give the IP address of the server in the try block. . 6. 7. Using while condition.is1 in the try block. 7. Catch the exception e. 4. Catch the exception e. Declare the object c for client as null. 6. Create the class EClient. 8. 8. 4.

println(e). while(true) { Line=is. try { s=new ServerSocket(9000).out.net. ps. } } } . } } catch(IOException e) { System.getInputStream()). String Line.*.readLine(). DataInputStream is.out.getOutputStream()).io.println(e). is=new DataInputStream(c.println(Line). public class Eserver { public static void main(String args[]) { ServerSocket s=null.java import java. } try { c=s.accept(). } catch(IOException e) { System. PrintStream ps.*. import java.PROGRAM: EServer. Socket c=null. ps=new PrintStream(c.

getInputStream()).out.println(Line).*.java import java.readLine()).getOutputStream()). os. is=new DataInputStream(System. try { c=new Socket("127.9000).println("client:"). while(true) { System.println(e).io.is1. PrintStream os.in). System.out. String Line. public class Eclient { public static void main(String args[]) { Socket c=null.0. import java.println("server:"+is1. } catch(IOException e) { System. } } catch(IOException e) { System.readLine(). }}} .EClient.out.net. is1=new DataInputStream(c.0. DataInputStream is.out.*.println("socket closed!"). Line=is. } try { os=new PrintStream(c.1".

Note: Recompile with -deprecation for details.5.5. Note: Recompile with -deprecation for details.java Note: EClient.0\bin>java EClient Client: Hai Server Server:Hai Server Client: Hello Server:Hello Client: end Server:end Client: ds Socket Closed! .java uses or overrides a deprecated API.java uses or overrides a deprecated API. C:\Program Files\Java\jdk1.5.5.0\bin> Client: C:\Program Files\Java\jdk1.0\bin>java EServer C:\Program Files\Java\jdk1.5.0\bin>javac EClient.java Note: EServer.0\bin>javac EServer. C:\Program Files\Java\jdk1.Output: Server: C:\Program Files\Java\jdk1.

RESULT: Thus the program for implementation of TCP/IP Echo was written and executed successfully.

EX.NO:04 (c) AIM:

PROGRAMS USING SIMPLE UDP

To write a client-server application for chat using UDP ALGORITHM: CLIENT 1. Include necessary package in java 2. To create a socket in client to server. 3. The client establishes a connection to the server. 4. The client accept the connection and to send the data from client to server and vice versa 5. The client communicate the server to send the end of the message 6. Stop the program. SERVER 1. Include necessary package in java 2. To create a socket in server to client 3. The server establishes a connection to the client. 4. The server accept the connection and to send the data from server to client and vice versa 5. The server communicate the client to send the end of the message 6. Stop the program.

PROGRAM : UDPserver.java import java.io.*; import java.net.*; class UDPserver { public static DatagramSocket ds; public static byte buffer[]=new byte[1024]; public static int clientport=789,serverport=790; public static void main(String args[])throws Exception { ds=new DatagramSocket(clientport); System.out.println("press ctrl+c to quit the program"); BufferedReader dis=new BufferedReader(new InputStreamReader(System.in)); InetAddress ia=InetAddress.getByName("localhost"); while(true) { DatagramPacket p=new DatagramPacket(buffer,buffer.length); ds.receive(p); String psx=new String(p.getData(),0,p.getLength()); System.out.println("Client:" + psx); System.out.println("Server:"); String str=dis.readLine(); if(str.equals("end")) break; buffer=str.getBytes(); ds.send(new DatagramPacket(buffer,str.length(),ia,serverport)); }}} UDPclient.java import java .io.*; import java.net.*; class UDPclient { public static DatagramSocket ds; public static int clientport=789,serverport=790; public static void main(String args[])throws Exception { byte buffer[]=new byte[1024]; ds=new DatagramSocket(serverport); BufferedReader dis=new BufferedReader(new InputStreamReader(System.in)); System.out.println("server waiting"); InetAddress ia=InetAddress.getByName("10.0.200.36"); while(true) {

ds.equals("end")) break.getData().send(new DatagramPacket(buffer.println("Client:").p.getBytes().println("Server:" + psx).length). String psx=new String(p. buffer=str.str. String str=dis.buffer. ds.out.length().clientport)).getLength()).0. } } } .System.receive(p).ia.readLine(). if(str. System. DatagramPacket p=new DatagramPacket(buffer.out.

Output Server C:\Program Files\Java\jdk1.0\bin>java UDPclient server waiting Client: Hai Server Server:Hello Clie Client: How are You Server:I am Fine w Client: end .java C:\Program Files\Java\jdk1.5.0\bin>java UDPserver press ctrl+c to quit the program Client:Hai Server Server: Hello Client Client:How are You Server: I am Fine what about you Client C:\Program Files\Java\jdk1.5.0\bin>javac UDPserver.5.java C:\Program Files\Java\jdk1.0\bin>javac UDPclient.5.

RESULT: Thus the above program a client-server application for chat using UDP was executed and successfully .

Declare the variables t1.v1. Add the button and declare it as t1. 8. 6. 5. Use „for‟ for interface and add all the commands. Create a variable b for button and assign the value. Create an interface action listener using the keyword implements. 10. Create the variable t1 using „this‟ keyword. 3. 4.clear and EQ. Create the subclass cal. 9. Create the variable OP as char type. 11.sub. Create the variable k for setting the color and also assign the value for text field and for gridlayout gl and assign the value. In the interface ActionListener. Create the button for add.div. ALGORITHM: 1.v2 result for int text field respectively.mul. . declare str and char and else if condition to perform the action specified.EX:NO:5 AIM: JAVA APPLET PROGRAM FOR CALCULATOR To write a java applet program for calculator.mod. 7. 2.

result.5).PROGRAM: import java. Button b[]=new Button[10].i<10. mod=new Button("mod"). add(sub). clear=new Button("clear").mul. for(int i=0.EQ.*.addActionListener(this). char OP.89. for(int i=0. public void init() { Color k=new Color(120. import java.awt.event.90). sub=new Button("sub"). EQ=new Button("EQ"). t1.*.clear.i++) { b[i]=new Button(""+i).v2. t1=new TextField(10). GridLayout gl=new GridLayout(4. add(mul).i++) { add(b[i]). import java. mul=new Button("mul"). setBackground(k). } add(add).awt. /* <applet code="Cal" width=300 height=300> </applet> */ public class Cal extends Applet implements ActionListener { String msg="". int v1.div. add(t1).mod.i<10.sub.applet. div=new Button("div"). TextField t1. Button add. setLayout(gl). .*. } add=new Button("add").

OP='-'. else if(str. } public void actionPerformed(ActionEvent ae) { String str=ae. t1.add(div).setText("").equals("mul")) { v1=Integer.addActionListener(this).equals("add")) { v1=Integer.equals("div")) { v1=Integer.addActionListener(this). OP='+'. } else if(str. add(clear). } else if(str. for(int i=0.getText()). OP='*'.addActionListener(this).i++) { b[i].getActionCommand().getText()+str).setText(""). mod.addActionListener(this).addActionListener(this). char ch=str. clear.isDigit(ch)) t1. add(mod). t1.equals("sub")) { v1=Integer.setText(""). add(EQ).getText()).parseInt(t1.parseInt(t1. } add.parseInt(t1.getText()).charAt(0).addActionListener(this).i<10.addActionListener(this).getText()).setText(t1.parseInt(t1. mul. div. if(Character. .addActionListener(this). sub. } else if(str. EQ. t1.

} if(str. else if(OP=='-') result=v1-v2. t1. } } .setText("").getText()). if(OP=='+') result=v1+v2. else if(OP=='*') result=v1*v2. } if(str. OP='%'.setText(""+result). else if(OP=='%') result=v1%v2.parseInt(t1.equals("EQ")) { v2=Integer.parseInt(t1. } else if(str.equals("mod")) { v1=Integer. t1.setText("").setText("").OP='/'.getText()). t1. else if(OP=='/') result=v1/v2.equals("clear")) { t1.

OUTPUT: } .

rectangles and ovals and create a calculator was written and executed successfully.RESULT: Thus the java applet program that allows the user to draw lines. .

EX NO:8 PROGRAMS USING RPC / RMI .

To Execute Start RMI registry 7. Start the program and to include necessary packages 2.Finally to call and compile all the sub program 6.Using public interface to call the program in remotely 5.Using Add server() to implement and Call the Add server impl 4. Using Add client to get the two values 3.Stop the program PROGRAM: .AIM: To implement the program using RMI ALGORITHM: 1.

} catch(Exception e) { System. } } } ADD SERVERIMPL: import java. import java.rmi.*.rmi. } catch(Exception e) { System.rebind("AddServer". public class AddClient { public static void main(String args[]) { try { String addServerURL="rmi://"+args[0]+"/AddServer".out. System. double d1=Double.println("Exception:"+e). Naming. } } } ADD SERVER import java. public class AddServer { public static void main(String args[]) { try { AddServerImpl addServerImpl=new AddServerImpl().out.add(d1. System.out.out.addServerImpl). .println("the Second number is"+args[2]). AddServerIntf addServerIntf=(AddServerIntf)Naming.valueOf(args[1]).println("Exception :"+e).ADD CLIENT: import java.d2)).println("the first number is"+args[1]).*.lookup(addServerURL).rmi.net.out.*.*. double d2=Double.valueOf(args[2]). System.doubleValue().doubleValue( ).println("the sum is "+addServerIntf.

server.*. public interface AddServerIntf extends Remote { double add(double d1.import java.*.double d2)throws RemoteException. } } ADDSERVERINTF: import java. } OUTPUT: .double d2)throws RemoteException { return d1+d2.rmi.rmi. public class AddServerImpl extends UnicastRemoteObject implements AddServerIntf { public AddServerImpl()throws RemoteException { } public double add(double d1.

.

EX NO: 9 ON-LINE EXAM USING SERVLETS .RESULT: Thus the Above program RMI was executed and successfully.

Insert 10 records 3. invoke the page and test PROGRAM . ALGORITHM: 1. add a table with the following fields Field Option1 Option2 Option3 Option4 Answer Question text text text text text text type 250 250 250 250 250 250 2. Create a database . compile the Source 5. Create a system DSN in the ODBC panel (onlineexam) 4.Date: AIM Develop an Servlet program to conduct online examination.

import javax. out.io. import java.setContentType("text/html"). out. import javax. int qno=1. out. ResultSet Recordset.net.print("<tr><td><input type='radio' value='2'>"+"</td><td>"+Recordset.servlet.*.servlet. IOException { response.next()) { out.getString(6)+"</td></tr>").print("<tr><td>Question no"+qno+"</td><td>"+Recordset. HttpServletResponse response) throws ServletException.print("<tr><td><input type='radio' value='3'>"+"</td><td>"+Recordset.print("<H3>Online Exam</h3>").print("<tr><td><input type='radio' value='1'>"+"</td><td>"+Recordset.getWriter(). out.print("<form name='form1' method='post' action='score'>").getString(2)+"</td></tr>"). try{ while (Recordset.http. int total=0. import java. PrintWriter out = response.getString(1)+"</td></tr>").*.getString(3)+"</td></tr>"). PreparedStatement StatementRecordset. out. public class Exam extends HttpServlet { Connection ConnRecordset. protected void processRequest(HttpServletRequest request. out. import java.print("<Table border=1>").*.package test.sql.*. name='opt"+qno+"' name='opt"+qno+"' name='opt"+qno+"' .*.

print("Error"+sqe).getString(4)+"</td></tr>"). ConnRecordset=DriverManager.print("<tr></tr><tr><td><input type='submit' name='Submit' value='Submit'>").close().getConnection("jdbc:odbc:onlineexam").prepareStatement("SELECT * FROM test"). StatementRecordset. } name='opt"+qno+"' out. out.print("<tr><td><input type='radio' value='4'>"+"</td><td>"+Recordset. ConnRecordset. out. } catch(SQLException sqe) { out. response).close(). qno=qno+1. } catch(Exception e){} processRequest(request.forName("sun.print("</form>").odbc. IOException { try{ Class. Recordset. StatementRecordset = ConnRecordset.close().close(). HttpServletResponse response) throws ServletException.executeQuery(). } } protected void doGet(HttpServletRequest request.out.jdbc. Recordset = StatementRecordset. OUTPUT } } .JdbcOdbcDriver").

.

RESULT: Thus servlet based online exam had been developed and tested EX NO:9 AIM: HTML PROGRAM TO CREATE ONLINE BOOK STORE .

7. the Book store web page is displayed. Otherwise. 2. 6. 8. error message will be displayed. Enter the URL in the web browser. Run the web browser.AIM: To develop a html Program to implement the online Book Store application. PROGRAM: Main page: <html> . Create the html Programs using notepad. Start the Program. Enter into the Login Page. ALGORITHM: 1. Browse the location of the file in the local disk. 4. Stop the program. Enter the id and password. 3. 5. If the id and password is valid.

html"> <input type="submit"value="click">registration user login hear </center> </body> </html> Login page: <html> <head> <title>login page</title> </head> <body> <center> <form method="post" action="login.html"> <p><strong>name:</strong> <input type="text" name="username" size="25"> </p> <p><strong>password</strong> <input name="pass" type="password" size="6"></p> <p><strong>male</strong> <input type="radio" value="male"<hacked>&nbsp&nbsp</p> <p><strong>female</strong> <option><input type="radio" value="female"<hacked>&nbsp.</p> <input type="submit" value="submit">&nbsp&nbps .<head> <title>home page</title> </head> <body> <center><b><h1>welcome to amazon.com</h1></b><br><br> <form method="post"action="login.

<input type="reset" value="reset"> <a href="registration.html">new users register hear </a> </form> </center> </body> </html> Books Catalog: <html> <head> <title>books catalog</title> </head> <body> <center><h1><p>welcome to books catalog</p></h1> <table border="1"width="25%"height="50%"> <tr> <th>computers</th> <th>electronics</th> <th>biotech</th> <th>mechanical</th> </tr> <tr> <td> </body> </html> OUTPUT: .

.

.

RESULT: Thus the HTML Program to implement the online Book Store application was written and executed successfully. .

2. 3. Display the welcome message for web page with dynamic effects. Start the Program. Create the xml. DISPLAY RECEIPIENT DETAILS USING XML . Browse the location of the file in the local disk. Document type definition Programs using notepad. . 7.EX NO:9 SCHEMATIC DESIGN USING XML (a). 5.DTD AIM: To write an XML DTD Program to Display Recipient Details for purchasing of Books. ALGORITHM: 1. 4. 6. Run the web browser. Stop the program. Enter the URL in the web browser.

xml: <? xml version="1.2001" > <recipient country="USA"> <name>RAVIKRISHNA</name> <street>7G.street.city.dtd"> <purchase Order order Date="07.order)> <!ELEMENT recipient (name.dtd: <?xml version="1.23.0" encoding="UTF-8"?> <!ELEMENT purchaseOrder (recipient.state)> <!ELEMENT name <!ELEMENT street <!ELEMENT city <!ELEMENT state (#PCDATA)> (#PCDATA)> (#PCDATA)> (#PCDATA)> <!ELEMENT order (cd)+> <!ELEMENT cd EMPTY> <!ATTLIST purchaseOrder orderDate CDATA #REQUIRED > <!ATTLIST recipient .PROGRAM: Po.0" encoding="UTF-8"?> <! DOCTYPE purchase Order SYSTEM "po.ADYAR</street> <city>CHENNAI-28</city> <state>TAMILNADU</state> </recipient> <order> <cd artist="Brooks Williams" title="Little Lion" /> <cd artist="David Wilcox" title="What you whispered" /> </order> </purchase Order> Po.RAINBOW COLONY.

width=100> <title> RECIPIENT DETAILS </title> </head> <body style="background-color: BLACK"> <H3 STYLE="COLOR: BLUE"> <MARQUEE DIRECTION="UP"> <p> BOOK DETAIL<BR> AUTHOR: Brooks Williams.jpg" height=100 .<BR>David Wilcox<BR>BOOK NAME: Little Lion.ADYAR <LI>CITY:CHENNAI-28 <LI>STATE:TAMILNADU </UL> </body> </html> .country CDATA #REQUIRED > <!ATTLIST cd artist CDATA #REQUIRED title CDATA #REQUIRED> po.dtd""> <Html> <head COLOR: BLACK><h1 style="color: WHITE"> <MARQUEE DIRECTION="right"><CENTER>PURCHASE ORDER </CENTER> </MARQUEE> </H1> <img src="C:\Documents and Settings\Administrator\Desktop\ATT4864414.RAINBOW COLONY.<br>What you whispered </MARQUEE></p> <p><marquee direction="UP"><h3 style="color: red">RECIPIENT DETAILS</P></marquee> <UL> <LI>NAME: RAVIKRISHNA <LI>STREET:7G.0 Transitional//EN" "po.html: <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.

OUTPUT: .

RESULT: Thus the Xml DTD Program to Display Recipient details for purchasing of books was written and executed successfully. .

XSL AIM: To write an XML XSL Program to Display the titles of the documents. 5. Browse the location of the file in the local disk. Run the web browser. Enter the URL in the web browser. Document type definition and xsl programs using notepad.Ex. 6. Display the web page with effects.No:11(b) Date: DISPLAY THE DOCUMENT USING XML . 7. 2. ALGORITHM: 1. 3. 4. Stop the program. Create the xml. Start the Program. .

section*)> <! ELEMENT section (title.XSL <xsl:stylesheet version="1. (para|note)*)> <! ELEMENT title (#PCDATA|emph)*> <! ELEMENT para (#PCDATA|emph)*> <! ELEMENT note (#PCDATA|emph)*> <! ELEMENT emph (#PCDATA|emph)*> DOC.0" xmlns:xsl="http://www. (para|note)*.PROGRAM: DOC.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict"> <xsl:strip-space elements="doc chapter section"/> <xsl:output method="xml" indent="yes" encoding="iso-8859-1"/> <xsl:template match="doc"> <html> <head> <title> <xsl:value-of select="title"/> </title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="doc/title"> <h1> <xsl:apply-templates/> .DTD <! ELEMENT doc (title.w3. chapter*)> <!ELEMENT chapter (title.

</h1> </xsl: template> <xsl:template match="chapter/title"> <h2> <xsl:apply-templates/> </h2> </xsl:template> <xsl:template match="section/title"> <h3> <xsl:apply-templates/> </h3> </xsl:template> <xsl:template match="para"> <p> <xsl:apply-templates/> </p> </xsl:template> <xsl:template match="note"> <p class="note"> <b>NOTE: </b> <xsl:apply-templates/> </p> </xsl:template> <xsl:template match="emph"> <em> <xsl:apply-templates/> </em> </xsl:template> </xsl:stylesheet> .

w3.xsl"?> <html xmlns="http://www.HTML <?xml version="1.org/TR/xhtml1/strict"> <head> <title>Document Title</title> </head> <body> <h1>Document Title</h1> <h2>Chapter Title</h2> <h3>Section Title</h3> <p>This is a test.</note> </section> <section> <title>Another Section Title</title> <para>This is <emph>another</emph> test.</para> <note>This is another note.</p> .0"?> <?xml-stylesheet type="text/xsl" href="doc.</note> </section> </chapter> </doc> DOC.</p> <p class="note"> <b>NOTE: </b>This is a note.DOC.XML <!DOCTYPE doc SYSTEM "doc.</para> <note>This is a note.dtd"> <doc> <title>Document Title</title> <chapter> <title>Chapter Title</title> <section> <title>Section Title</title> <para>This is a test.</p> <h3>Another Section Title</h3> <p>This is <em>another</em> test.

</p> </body> </html> .<p class="note"> <b>NOTE: </b>This is another note.

OUTPUT: .

.RESULT: Thus the Xml XSL Program to Display the titles of the documents was written and executed successfully.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.