CS2358 – INTERNET PROGRAMMING LABORATORY ...

117 downloads 249 Views 2MB Size Report
IP LAB MANUAL. 2. Ms.B.NIRMALA AP/CSE. GENERAL INSTRUCTIONS FOR LABORATORY CLASSES. DO'S o Without Prior permission do not enter into the  ...
IP LAB MANUAL

CS2358 – INTERNET PROGRAMMING LABORATORY LABORATORY MANUAL FOR VI SEMESTER B.E / CSE ACADEMIC YEAR: 2013 – 2014 (EVEN) (FOR PRIVATE CIRCULATION ONLY) ANNA UNIVERSITY, CHENNAI.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

DR.NAVALAR NEDUNCHEZHIAYN COLLEGE OF ENGINEERING, THOLUDUR-606303, CUDDALORE DIST.

1 Ms.B.NIRMALA AP/CSE

IP LAB MANUAL

GENERAL INSTRUCTIONS FOR LABORATORY CLASSES DO’S o

Without Prior permission do not enter into the Laboratory.

o

While entering into the LAB students should wear their ID cards.

o

The Students should come with proper uniform.

o

Students should sign in the LOGIN REGISTER before entering into the laboratory.

o

Students should come with observation and record note book to the laboratory.

o

Students should maintain silence inside the laboratory.

o

After completing the laboratory exercise, make sure to shutdown the system properly. DONT’S

o Students bringing the bags inside the laboratory.. o Students wearing slippers/shoes insides the laboratory. o Students using the computers in an improper way. o Students scribbling on the desk and mishandling the chairs. o Students using mobile phones inside the laboratory. o Students making noise inside the laboratory.

2 Ms.B.NIRMALA AP/CSE

IP LAB MANUAL HARDWARE REQUIREMENTS:

Pentium IV with 2 GB RAM, 160 GB HARD Disk, Monitor 1024* 768 color 60Hz SOFTWARE REQUIREMENTS:

Windows / Linux operating system Any Browser UNIVERSITY PRACTICAL EXAMINATION

Allotment of marks Internal assessment Practical examination Total

= 20 marks = 80 marks --------------------= 100 marks ---------------------

INTERNAL ASSESSMENT (20 marks) Staff should maintain assessment register and the HOD should monitor it

Split up of Internal Marks Observation Record Note Modal Exam Attendance Total

= 3 marks = 7 marks = 5 marks = 5 marks --------------------= 20 marks --------------------UNIVERSITY EXAMINATION

The exam will be conducted for 100 marks. Then the marks will be calculated to 80 marks

Split up of Practical Examination Marks Aim and Procedure

=

30 marks

Program

=

30 marks

Execution

=

20 marks

Output & result

=

10 marks

Viva voce

= 10 marks --------------------= 100 marks ---------------------

Total

3 Ms.B.NIRMALA AP/CSE

IP LAB MANUAL

CS2358 – INTERNET PROGRAMMING LABORATORY

LIST OF EXPERIMENTS 1. Web page creation using HTML i) To embed an image map in a web page ii) To fix the hot spots iii)

Show all the related information when the hot spots are clicked.

2. Web page creation with all types of Cascading style sheets 3. Client side scripts for validating web form controls using DHTML 4. Java programs to create applets i) Create a color palette with matrix of buttons ii) Set background and foreground of the control text area by selecting a color from color palette. iii)

In order to select foreground or background use check box control as radio buttons.

iv)

To set background images.

5. Programs in java using servlets 6. Programs in java to create three-tier applications using JSP and Databases i) for conducting online examination ii) for displaying students mark list. 7. Programs using XML-schema-XSLT/XSL 8. Programs using AJAX 9. Implementation of web services and databases.

4 Ms.B.NIRMALA AP/CSE

IP LAB MANUAL

S. No

1.

Page No

CONTENTS

NAME OF THE EXPERIMENTS

Web page creation using HTML

6

Web page creation with all types of Cascading style 2.

11

sheets Client side scripts for validating web form controls using

3.

14

DHTML

4.

Java programs to create applets

16

5.

Programs in java using servlets

20

Programs in java to create three-tier Applications using 6.(a)

23

jsp and databases Student Marklist Using Servlet

28

7.

Program Using Xml - Xslt

32

8.

Program Using Dom With Xml

35

9.

Program Using Sax With Xml

38

10.

Program Using Ajax

41

11.

Implementation of web services and databases.

44

12.

BEYOND THE SYLLABUS Displaying time using HTML

48

13.

Menus and menugroup using HTML

50

6(b)

5 Ms.B.NIRMALA AP/CSE

IP LAB MANUAL

Exercise Number: 1 Title of the exercise

: WEB PAGE CREATION USING HTML

Date of the exercise

:

OBJECTIVE (AIM) OF THE EXPERIMENT To create a web page which includes a map and display the related information when a hot spot is clicked in the map. FACILITIES REQUIRED AND PROCEDURE a)

Facilities Required: S.No.

Facilities required

Quantity

1

System

1

2

O/S

Windows / Linux OS

3

S/W name

Any Browser

b) Procedure: Step no. 1 2 3 4 5 c)

Details of the step Create a html file with map tag Set the source attribute of the img tag to the location of the image and also set the use map attribute Specify an area with name, shape and href set to the appropriate values Repeat step 3 as many hot spots you want to put in the map Create html files for each and every hot spots the user will select Program:

ImageMap.html Image Map

6 Ms.B.NIRMALA AP/CSE

IP LAB MANUAL TamilNadu.html About Tamil Nadu

Tamil Nadu


  • Area : 1,30,058 Sq. Kms.
  • Capital : Chennai
  • Language : Tamil
  • Population : 6,21,10,839

India Map Karnataka.html About Karnataka

Karnataka


  • Area : 1,91,791 Sq. Kms
  • Capital : Bangalore
  • Language : Kannada
  • Population : 5,27,33,958

India Map AndhraPradesh.html About Andhra Pradesh

Andhra Pradesh


  • Area : 2,75,068 Sq. Kms
  • Capital : Hyderabad
  • Language : Telugu
  • Population : 7,57,27,541

India Map 7 Ms.B.NIRMALA AP/CSE

IP LAB MANUAL Kerala.html About Kerala

Kerala


  • Area : 38,863 Sq. Kms.
  • Capital : Thiruvananthapuram
  • Language : Malayalam
  • Population : 3,18,38,619

India Map

d)

Output:

8 Ms.B.NIRMALA AP/CSE

IP LAB MANUAL

9 Ms.B.NIRMALA AP/CSE

IP LAB MANUAL

e)

Result: Thus the creation of a web page which includes a map and display the related information when a hot spot is clicked in the map was executed successfully

VIVA QUESTIONS AND ANSWERS: 1. What are the three major components of HTML document?  HTML declaration  The head  The body 2. List out some of the HTML tags?
  • , ,
    ,
    ,
    , ,
      , 3. What kind of tag is HTML? Every HTML tag is either a container tag or standalone tag. 4. How to format tags? HTML provides a host of tags that we can use to change hoe text is displayed on a browser screen. 5. Define HTML. It is a simple page description language, which enables document creation for the web. 6. List out the document structure tags. , , , , , , , , , , and .

      10 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      Exercise Number: 2 Title of the exercise : CASCADING STYLE SHEETS Date of the exercise : OBJECTIVE (AIM) OF THE EXPERIMENT To create a web page that displays college information using various style sheet FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step no.

      Details of the step

      1

      Create a web page with frame sets consisting two frames

      2

      In the first frame include the links

      3

      In the second frame set display the web page of the link

      4

      create a external style sheets

      5

      create a inline and internal style sheets and make it link to the external style sheets

      c)Program:/

      XYZ.CSS: h3{font-family:arial;font-size:20;color:cyan} table{border-color:green} td{font-size:20pt;color:magenta}

      HTML CODE:

      ALL STYLE SHEETS

      USE of INTERNAL and EXTERNAL STYLESHEETS .vid{font-family:verdana;font-style:italic;color:red;text-align:center} 11 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL .ani{font-family:tahoma;font-style:italic;font-size:20;text-align:center;} font{font-family:georgia;color:blue;font-size:20} ul{list-style-type:circle}
        ARUMUGA MUDHALIYAR GROUP OF INSTITUTIONS


      1. Dr.Navalar Nedunchezhiyan college of engineering
      2. Arumugham Polytechnic college
      3. Arumugham arts and science
      4. Arumugham teacher training

      Dr.NNCE

      Arumugham Group of colleges is owned by A.Krishnaswami
      It is approved by AICTE(All India Council for Technical Education). It is affliated to Anna University.

      Dr.Navalar Nedunchezhiyan college of engineering


      It is an ISO certified Institution

      List of Courses offered

      • Computer Science and Engineering
      • Ece
      • mech
      • eee

      Results of cse students

      12 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL
      S.NAME MARKS RESULT
      Suppriya 100 pass
      Devishree 99 pass
      Vinayagam 98 pass
      d)Output:

      e)Result: Thus the creation of a web page that displays college information using various style sheet was successfully executed and verified. /CDlgDlg.cpp VIVA – QUESTIONS AND ANSWERS: 1.

      What is CSS? CSS stands for Cascading Style Sheets. Styles define how to display HTML elements. 2. List the features of CSS?  Text handling including fonts, sizing, styles and spacing.  Printing specific features, downloadable fonts  Support for vertical running text, multicolumn layout facilities. 3. What are the three main parts of CSS syntax? The CSS syntax is made up of three parts: a selector, a property and a value. Selector {property: value} 1. The selector is normally the HTML element/tag we wish to define. 2. The property is the attribute we wish to change and each property can take a value. 3. The property and value are sepaerated by a colon and surrounded by curly braces. 4. How to insert a style sheet? When a browser reads a style sheet, it will format the document according to it. There are three ways of inserting a style sheet:  External Style Sheet  Internal Style Sheet  Inline styles  Multiple style sheets

      13 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      Exercise Number: 3 Title of the exercise

      :

      Date of the exercise

      :

      VALIDATING WEB FORM CONTROLS USING DHTML

      OBJECTIVE (AIM) OF THE EXPERIMENT To create a Client Side Scripts for Validating Web Form Controls using DHTML FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step no.

      Details of the step

      1

      The form will include one text field called " Name", and a submit buton.

      2

      Validation script will ensure that the user enters their name before the form is sent to the server. Open this page to see it in action.

      3 4 5 6

      Try pressing the Send Details button without filling anything in the "Name” field. We might like to open the source code for this form in the separate window. The page consists of a JavaScript function called validate_form() that performs the form validation, followed by the form itself.

      c) Program: A Simple Form with JavaScript Validation
      IP LAB MANUAL return valid; } //-->

      Please Enter Your Name

      Your Name:

      d)Output:

      e)Result: Thus to create a Client Side Scripts for Validating Web Form Controls using DHTML was successfully executed and verified. VIVA – QUESTIONS AND ANSWERS: 1. Define: DHTML Dynamic HTML is a term used by some vendors to describe the combination of HTML, style and scripts that allow documents to be animated. 2. How to access an element in DHTML? The element must have an id attribute defined and a scripting language is needed. 3. List the DHTML document object model.    

      Window Document Navigator Event

      15 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      Exercise Number: 4 Title of the exercise

      : JAVA PROGRAMS TO CREATE APPLETS

      Date of the exercise

      :

      OBJECTIVE (AIM) OF THE EXPERIMENT i. ii. iii. iv.

      To create applets with the following features Create a color palette with matrix of buttons. Set background and foreground of the control text area by selecting a color from color palette. In order to select foreground or background use checkbox controls as radio buttons. To set background images.

      FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step

      Details of the step

      no. 1

      Import all necessary packages and classes

      2

      Define a class that extends applet and implements action listener and item listener

      3 4

      Declare an array of buttons to set colors, two checkboxes for foreground and background colors Declare a text area to hold the text, a checkbox group for checkboxes

      5

      Add the array of buttons in the init function

      6

      In the actionPerformed() method, do the following: i) Get the action command in the string, color ii) If foreground is checked then set the foreground color to the selected color iii) If background is checked then set the background color to the selected color

      c)Program:e import java.awt.*; import java.awt.event.*; import java.applet.*; /* */ public class exp extends Applet implements ItemListener { 16 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL int currcolor=5; int flag=1; String text="Click any of the buttons"; Button buttons[]=new Button[5]; String colours[]={"Red","Blue","Green","Yellow","Magenta"}; Image img; CheckboxGroup cbg=new CheckboxGroup(); Checkbox box1=new Checkbox("Background Color",cbg,true); Checkbox box2=new Checkbox("Text Color",cbg,false); Checkbox box3=new Checkbox("Loading Image",cbg,false); u public void init() { for(int i=0;iappletviewer ColorPalette.java

      e)Result: Thus the java program to create applet was successfully executed and verified. VIVA – QUESTIONS AND ANSWERS: 1. What is Applet? A Java applet is a small application written in Java and delivered to users in the form of bytecode. 2. What is servlet? The servlet is a Java programming language class used to extend the capabilities of a server 3. What do you mean by Encapsulation? Encapsulation – refers to keeping all the related members (variables and methods) together in an object. Specifying members as private can hide the variables and methods. 4. What are the benefits of the Java collection framework? Collection framework provides flexibility, performance, and robustness. 1. Polymorphic algorithms – sorting, shuffling, reversing, binary search etc. 2. Set algebra - such as finding subsets, intersections, and unions between objects.

      19 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      Exercise Number: 5 Title of the exercise

      : PROGRAMS IN JAVA USING SERVLETS

      Date of the exercise

      :

      OBJECTIVE (AIM) OF THE EXPERIMENT To write html and servlet to demonstrate invoking a servlet from a html. FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step no.

      Details of the step

      Client: 1 2

      In index.jsp on the client side declare the contents that you like to transfer to the server using html form and input type tags. create a submit button and close all the included tags.

      Server: 1 2

      In the servlet side using the parameter request get the stings declared in the client side (requst.getparameter) Include necessary html coding that helps to display the content

      c)Program:

      Servlet Code: import java.io.*; import java.util.*; import javax.servlet.*; public class PostParam extends GenericServlet { public void service(ServletRequest request,ServletResponse response) throws ServletException,IOException { PrintWriter pw = response.getWriter(); Enumeration e = request.getParameterNames(); while(e.hasMoreElements()) { String pname = (String)e.nextElement(); pw.print(pname + " = "); String pvalue = request.getParameter(pname); 20 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL pw.println(pvalue); } pw.close(); } }

      HTML CODE: INVOKING SERVLET FROM HTML
      Employee
      Phone
      d)Output:

      21 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      e)Result: Thus to write html and servlet to demonstrate invoking a servlet from a html was successfully executed and verified. VIVA – QUESTIONS AND ANSWERS: 1. List out the basic Internet Protocols. TCP/IP, POP3, MIME, IMAP 2. What are Web Servers? A Web Server is software that accepts HTTP requests from web clients and returns an appropriate resource in the HTTP response. 3. Define Web Clients. A Web Client is software that accesses a web server by sending an HTTP request message and processing the resulting HTTP response.

      22 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      Exercise Number: 6(a) Title of the exercise

      : PROGRAMS IN JAVA TO CREATE THREE-TIER APPLICATIONS USING JSP AND DATABASES

      Date of the exercise

      :

      OBJECTIVE (AIM) OF THE EXPERIMENT To write java servlet programs to conduct online examination and to display student mark list available in a database FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step no.

      Details of the step

      Client: 1 2

      In index.html on the client side declare the contents that you like to transfer to the server using html form and input type tags. create a submit button and close all the included tags.

      Servlet: 1

      Import all necessary packages

      2

      Define a class that extends servlet

      3

      In the doPost() method, do the following: i) Set the content type of the response to "text/html" ii) Create a writer to the response iii) Get a paratmeter from the request iv) If its value is equal to right answer then add 5 to mark variable v) Similarly repeat step vi) for all parameters vii) Display the result in an html format using the writer

      Student Mark List Database 1

      Import necessary to java packages and javax packages and classes

      2

      Create a class that extends HttpServlet and implements ServletException and IOException In the doGet() method, do the following: i) Create a PrintWriter object ii) Open a connection with the data source name iii) Write a sql query and execute to get the resultset iv) Display the resultset information in html form

      3

      23 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL c)Program:/

      SERVLET CODE: import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class StudentServlet3 extends HttpServlet { String message,Seat_no,Name,ans1,ans2,ans3,ans4,ans5; int Total=0; Connection connect; Statement stmt=null; ResultSet rs=null; public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { try { String url="jdbc:odbc:NEO"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connect=DriverManager.getConnection(url," "," "); message="Thank you for participating in online Exam"; } catch(ClassNotFoundException cnfex){ cnfex.printStackTrace(); } catch(SQLException sqlex){ sqlex.printStackTrace(); } catch(Exception excp){ excp.printStackTrace(); } Seat_no=request.getParameter("Seat_no"); Name=request.getParameter("Name"); ans1=request.getParameter("group1"); ans2=request.getParameter("group2"); ans3=request.getParameter("group3"); ans4=request.getParameter("group4"); ans5=request.getParameter("group5"); if(ans1.equals("True")) Total+=2; if(ans2.equals("False")) Total+=2; if(ans3.equals("True")) Total+=2; if(ans4.equals("False")) Total+=2; if(ans5.equals("False")) 24 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL Total+=2; try { Statement stmt=connect.createStatement(); String query="INSERT INTO student("+"Seat_no,Name,Total"+") VALUES('"+Seat_no+"','"+Name+"','"+Total+"')"; int result=stmt.executeUpdate(query); stmt.close(); }catch(SQLException ex){ } response.setContentType("text/html"); PrintWriter out=response.getWriter(); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println("

      "+message+"

      \n"); out.println("

      Yours results stored in our database

      "); out.print("

      "); out.println(""+"Participants and their Marks"+""); out.println(""); try { Statement stmt=connect.createStatement(); String query="SELECT * FROM student"; rs=stmt.executeQuery(query); out.println(""); out.println(""); out.println(""); while(rs.next()) { out.println(""); out.print(""); out.print(""); out.print(""); out.println(""); } out.println("
      "+"Seat_no"+""+"Name"+""+"Marks"+"
      "+rs.getInt(1)+""+rs.getString(2)+""+rs.getString(3)+"
      "); } catch(SQLException ex){ } finally { try { if(rs!=null) rs.close(); if(stmt!=null) stmt.close(); if(connect!=null) 25 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL connect.close(); } catch(SQLException e){ } } out.println(""); out.println(""); Total=0; }} HTML CODE: Database Test

      Online Examination


      Seat Number:
      Name:


      1. Every host implements transport layer.
      True False
      2. It is a network layer's responsibility to forward packets reliably from source to destination
      True False
      3. Packet switching is more useful in bursty traffic
      True False
      4. A phone network uses packet switching
      True False
      5. HTML is a Protocol for describing web contents
      True False







      26 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      d)Output:

      e)Result: Thus to write java servlet programs to conduct online examination and to display student mark list available in a database was successfully executed and verified. VIVA – QUESTIONS AND ANSWERS: 1. Define protocol. A protocol is a formal set of rules that must be followed in order to communicate. 2. What is the role of server? The server • Manages application tasks • Handles storage • Handles security • Provides scalability • Handles accounting and distribution 3. Define internet . Network is an interconnection of systems to share data and information. Internet is network of network or collection of heterogeneous networks.

      27 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      Exercise Number: 6(b) Title of the exercise Date of the exercise

      : STUDENT MARKLIST USING SERVLET :

      OBJECTIVE (AIM) OF THE EXPERIMENT To create a three tier application for displaying the student marklist FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step no.

      Details of the step

      Client: 1 2

      In index.html on the client side declare the contents that you like to transfer to the server using html form and input type tags. create a submit button and close all the included tags.

      Servlet: 1

      Import all necessary packages

      2

      Define a class that extends servlet

      3

      In the doPost() method, do the following: i)Set the content type of the response to "text/html" ii) connect with the database which has the student marklist iii) query the data to the database Display the student marklist

      4 c)Program:/

      SERVLET CODE: import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class serv extends HttpServlet { String message,Reg_no; Connection connect; Statement stmt=null; ResultSet rs=null; 28 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { try { S String url="jdbc:odbc:NEO"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connect=DriverManager.getConnection(url," "," "); message="Mark List"; } catch(ClassNotFoundException cnfex){ cnfex.printStackTrace(); } catch(SQLException sqlex){ sqlex.printStackTrace(); } catch(Exception excp){ excp.printStackTrace(); } Reg_no=request.getParameter("regno"); response.setContentType("text/html"); PrintWriter out=response.getWriter(); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println("

      "+message+"

      \n"); DI try { Statement stmt=connect.createStatement(); String query=new String("SELECT * FROM MarkList WHERE regno= "+Reg_no); rs=stmt.executeQuery(query); boolean b=rs.next(); out.println("Regsitration No:"+rs.getInt(1)); out.println("
      "+"Name:"+rs.getString(2)); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); while(b) { out.println(""); out.print(""); out.print(""); out.print(""); out.print(""); out.println(""); b=rs.next();} out.println("
      "+"cs01"+""+"cs02 "+""+"cs03"+""+"status"+"
      "+rs.getString(3)+""+rs.getString(4)+""+rs.getString(5)+""+rs.getString(6)+"
      "); } catch(SQLException ex){ out.println("error in connection"); } finally 29 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL { try { if(rs!=null) rs.close(); if(stmt!=null) stmt.close(); if(connect!=null) connect.close(); } catch(SQLException e){ } } out.println(""); out.println(""); } }

      HTML CODE: mark sheet

      Student Mark Sheet

      registration number:

      ializeDoc.cpp d)Output:

      30 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      e)Result: Thus to create a three tier application for displaying the student marklist was successfully executed and verified. VIVA – QUESTIONS AND ANSWERS: 1. Define firewall. The hardware and software that sits between the Internet and the local network, checking all the data that comes and goes out is called “firewalls”. The security is provided using SSL(Secure Socket Layer) in internet. 2. What is the use of http protocol? HTTP is a standard protocol that defines how a web client talks to a server and how data is transferred from the server back to the client. HTTP relies heavily on two other standards. MIME (Multipurpose Internet Mail Extensions), HTML 3. Define port. A port is a logical channel to an application running on a host. ie., The applications running on the host machines are uniquely identified by port numbers.

      31 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      Exercise Number: 7 Title of the exercise : PROGRAM USING XML - XSLT Date of the exercise : OBJECTIVE (AIM) OF THE EXPERIMENT To implement XSLT in XML document. FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step no.

      Details of the step

      1

      Start the program

      2

      Create an XML document with the details of the student such as name, address, standard and mark.

      3

      Import an XSL file to the xml file.

      4

      The XSL file imported puts the details of the students given in the xml file in a table and gets the details of each student from the xml file using the value-of attribute. The output in the browser would be the details from the XML file with

      5

      the style specified in XSL applied to it. 6

      Stop the program.

      c)Program: Info.XML: gokila neyveli 3rd yr 98 32 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL sivamani andimadam 3rd yr 95 sivasangari kumbakonam 3rd yr 98 sangeetha pennadam 3rd yr 88 Detail.XSL:

      student database

      name addr std mark
      33 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL d)Output:

      c)

      Result: Thus to implement XSLT in XML document was executed successfully and

      verified. VIVA – QUESTIONS AND ANSWERS: 1. What is the purpose of XSLT? The XSLT stands for XSL Transformations and XSL stands for eXtensible Stylesheet Language. The XSLT is used for defining the XML document transformation and presentations. 2. What is the use of XML declaration? XML declaration is a special tag used to specify the version of XML used to write the document and optionally some additional meta-information about the document such as the character set/encoding used. For e.g the syntax of XML declaration is 3. What are XML Parsers? XML Parsers are used to check whether the document is well formed and valid. 4. What are the types of XML Parsers?  Validating Parsers  Non-Validating Parsers

      34 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      Exercise Number: 8 Title of the exercise : PROGRAM USING DOM WITH XML Date of the exercise : OBJECTIVE (AIM) OF THE EXPERIMENT To write a program using SAX along with XML file. FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step no.

      Details of the step

      1

      Start the program

      2

      Keep the xml and java file in the same folder.

      3

      Import the required packages initially.

      4

      Use Buffer Reader to read the contents from the command prompt.

      5

      Get the name of the xml file from the user to execute.

      6

      Using XML Reader Factory obtain the parser.

      7

      If the document is correctly parsed then print document is well formed else print document is not well formed.

      c)Program:

      Parsing_DOMDemo.java: import java.io.*; import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*; public class Parsing_DOMDemo { static public void main(String[] arg) { try { 35 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL System.out.print("Enter the name of XML document "); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String file_name = input.readLine(); File fp = new File(file_name); if(fp.exists()) { try{ DocumentBuilderFactory Factory_obj = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = Factory_obj.newDocumentBuilder(); InputSource ip_src = new InputSource(file_name); Document doc = builder.parse(ip_src); System.out.println(file_name + " is well-formed!"); } catch (Exception e) { System.out.println(file_name + " isn't well-formed!"); System.exit(1); }} else { System.out.print("File not found!"); }} catch(IOException ex) { ex.printStackTrace(); }}} d)Output: sax.xml: SHARAN

      After Validating: sax.xml: SHARAN

      36 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL

      e)Result: Thus the Linked list program was compiled and executed successfuly. VIVA – QUESTIONS AND ANSWERS: 1. What is DOM? DOM (Document Object Model) is an API that defines how JavaScript programs can access and manipulate the HTML document currently displayed by a browser. It includes the definition of the properties of document object, many of which are themselves objects with their own properties. 2. What is Node object? Every element in a document tree refers to a Node object. Some nodes of the tree are JavaScript objects corresponding to HTML elements such html or body 3. Define Thread. A thread is the Java VM’s abstract representation of the processing to be performed to accomplish a particular task, possibly concurrently with other tasks 4. List out the methods of Cookie class. Cookie, getName(), getValue(), setMaxAge()

      Exercise Number: 9 37 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL Title of the exercise

      : PROGRAM USING SAX WITH XML

      Date of the exercise

      :

      OBJECTIVE (AIM) OF THE EXPERIMENT To write a program using SAX along with XML file. FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step no.

      Details of the step

      1

      Start the program

      2

      Keep the xml and java file in the same folder.

      3

      Import the required packages initially.

      4

      Use Buffer Reader to read the contents from the command prompt.

      5

      Get the name of the xml file from the user to execute.

      6

      Using XML Reader Factory obtain the parser.

      7

      If the document is correctly parsed then print document is well formed else print document is not well formed.

      8

      Stop the program.

      c)Program: import java.io.*; import org.xml.sax.*; import org.xml.sax.helpers.*; public class Parsing_SAXDemo{ public static void main(String[] args) throws IOException { try { System.out.print("Enter the name of XML document "); BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

      String file_name = input.readLine(); File fp = new File(file_name); 38 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL if (fp.exists()) { try { XMLReader reader = XMLReaderFactory.createXMLReader();

      reader.parse(file_name); System.out.println(file_name + " is well-formed."); } catch (Exception e) { System.out.println(file_name + " is not well-formed."); System.exit(1);}} else { System.out.println("File is not present: " + file_name);} catch (IOException ex){ex.printStackTrace();}}}

      }

      two.xml SURESH

      d)Output: XMLnot well formed program:

      XML well formed program:

      two.xml 39 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL SURESH

      e)Result: Thus to write a program using SAX along with XML file was successfully executed and verified. VIVA – QUESTIONS AND ANSWERS: 1. What is XML Namespace? An XML namespace is a collection of element and attribute names. Each namespace has a unique name that provides a means for document authors to unambiguously refer to elements with the same name in order to prevent collisions 2. What are XML Schemas? XML Schemas are part of the XML vocabulary and its addresses the standard for XML document validation by including a definition of a collection of standard data types which are used to describe data structures 3. What are the components of XSL?  XSLT-XSL Transformations which defines the semantics of the various elements and attributes of the XSL namespace.  XPATH – XML Path Language which defines the syntax and semantics of many of the attribute values used in XSL elements for accessing positions of the input XML  XSL-FO – XSL Formatting Objects is a separate vocabulary for defining style properties of an XML document.

      Exercise Number: 10 40 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL Title of the exercise Date of the exercise

      : PROGRAM USING AJAX :

      OBJECTIVE (AIM) OF THE EXPERIMENT To write programs to search and display chemistry element’s definition detail using JSP. FACILITIES REQUIRED AND PROCEDURE a) Facilities Required: S.No.

      Facilities required

      Quantity

      1

      System

      1

      2

      O/S

      Windows / Linux OS

      3

      S/W name

      Any Browser

      b) Procedure: Step no.

      Details of the step

      1

      Start the Program

      2

      Enter the chemistry element in index.html

      3

      Read the element data by request.getParameter() on chems.jsp.

      4

      Check given element in element list.

      5

      Display the definition of given element.

      6

      Stop the Program

      c)Program: Chems.html function loadXMLDoc(){ var xmlhttp; var data = (t1.value); if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();} else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; }} 41 Ms.B.NIRMALA AP/CSE

      IP LAB MANUAL xmlhttp.open("GET","chems.jsp?t1="+data,true); xmlhttp.send(); }



      Enter the Chem Name :
      Chem Name :
      Change Content


      chems.jsp