0% found this document useful (0 votes)
17 views44 pages

Web Technology Lab

The document outlines various examples of web development tasks, including creating image maps using HTML, building a website with CSS, validating web forms with DHTML, installing Apache Tomcat, and invoking servlets from HTML forms. Each example includes an aim, algorithm, and program code to demonstrate the concepts. The results indicate successful execution for each task.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views44 pages

Web Technology Lab

The document outlines various examples of web development tasks, including creating image maps using HTML, building a website with CSS, validating web forms with DHTML, installing Apache Tomcat, and invoking servlets from HTML forms. Each example includes an aim, algorithm, and program code to demonstrate the concepts. The results indicate successful execution for each task.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 44

Ex:01 Image Mapping using Html

Date:

AIM:

To Create a web page using HTML to insert a image map, fix the hotspots on it and show the
information about it in a web page.

ALGORITHM:

Home.html

1. Start the program.


2. Get the India map image and link it to the package

<img align="center" size="100" src="india.png" usemap="#india"/>

3. Fix the hotspots in that image.


4. Map the reference of the hotspots in the image.

<area shape="circle" coords="357,500,30" href="ANDHRAPRADESH.html">

<area shape="circle" coords="300,600,30" href="KERALA.html">

<area shape="circle" coords="300,500,30" href=" KARNATAKA.html">

<area shape="circle" coords="350,600,30" href="TAMILNADU.html">

5. Mention the derived link.


6. Click the link to get the desired image.
7. Stop the program.

PROGRAM:
HOME.html

<html>

<head>

<title>Home - States of India!!!</title>

</head>

<body bgcolor="gold">

<h1><u><center>Republic of India</center></u></h1>
<p>

India is the Seventh Lagest country in the world by geographical area, the second

most populous country with over 1.2 billion people, and the populus democracy in the

world. India is a federal constitutional republic with a parliamentry democracy consisting

of 28 states and 7 union Terriories.

</p>

<center>

<img align="center" size="100" src="india.png" usemap="#india"/>

<map name="india">

<area shape="circle" coords="357,500,30" href="ANDHRAPRADESH.html">

<area shape="circle" coords="300,600,30" href="KERALA.html">

<area shape="circle" coords="300,500,30" href=" KARNATAKA.html">

<area shape="circle" coords="350,600,30" href="TAMILNADU.html">

</map>

</center>

<h2> Features</h2>

<ul>

<li><b>Population</b> - 1,028,783,343(2001 census).

<li><b>Capital</b> - New Delhi

<li><b>Largest City</b> - Mumbai

<li><b>Currency</b> - Indian Rupee

<li><b>Time Format</b> - IST (UTC + 5:30)

<li><b>NAtion Sport</b> - Hockey

<li><b>Current PM</b> - Narendra Modi

<li><b>Current President</b> - Ram NathKovind

</li>

</ul>
<h2>

<b>To view details of states please click on the specified area in the

map !!!</b>

</h2>

</body>

</html>

ANDHRAPADESH.html

<html>

<head><title>Andhra Pradesh - India</title></head>

<body bgcolor="tan">

<h1><center>Andhra Pradesh</center></h1>

<h3>A.P., is a state situated on the southeastern coast of India. It is

India's fourth largest state by area and fifth largest by population.</h3>

<h3>

<ul>

<li>Districts<i> - 23</i>

<li>Capital City<i> - Hyderabad</i>

<li>Largest City<i> - Hyderabad</i>

<li>Governor<i> - BiswabhusanHarichandan</i>

<li>Chief Minister<i> -YS Jagan Mohan Reddy</i>

<li>Population<i> - 78,323,330</i>

<li>Tourist spots<i> - Tirumala Tirupati, Charminar, Golconda Fort,

Chandragiri, Chowmahalla Place, Falaknuma Palace etc.,</i>

</ul>

<a href="Home.html">back</a>

</body>

</html>
KERALA.html

<html>

<head><title>Kerala - India</title></head>

<body bgcolor="indianred">

<h1><center>Kerala</center></h1>

<h3>

<ul>

<li>Districts<i> - 14</i>

<li>Capital City<i> - Thiruvanandapuram</i>

<li>Largest City<i> - Thiruvanandapuram</i>

<li>Governor<i> - Arif Mohammad Khan</i>

<li>Chief Minister<i> -PinarayiVijayan</i>

<li>Population<i> - 33,387,677</i>

<li>Tourist spots<i> - Edakkal Caves, Palayur, KovalamBeach,Munnar, Kochi,

Alapuzha etc.,</i>

</ul>

</h3>

<a href="Home.html">Back</a>

</body>

</html>

KARNATAKA.html

<html>

<head><title>Karnataka - India</title></head>

<body bgcolor="wheat">

<h1><center>Karnataka</center></h1>

<h3>
<ul>

<li>Districts<i> - 30</i>

<li>Capital City<i> - Bangalore</i>

<li>Largest City<i> - Bangalore</i>

<li>Governor<i>- Hansraj Bhardwaj</i>

<li>Chief Minister<i> - D. V. Sadananda Gowda</i>

<li>Population<i> - 61,130,704</i>

<li>Tourist spots<i> - GolGumbaz, Mysore Palace, Keshava Temple etc.,</i>

</ul>

</h3>

<a href="Home.html">back</a>

</body>

</html>

TAMILNADU.html

<html>

<head><title>Tanil Nadu - India</title></head>

<body bgcolor="palegreen">

<h1><center>Tamil Nadu</center></h1>

<h3>is one of the 28 states of India. Its capital and largest city is Chennai.

Tamil Nadu lies in the southernmost part of the Indian Peninsula and

is bordered by the States of puducherry, Kerala, Karnataka, Andha Pradesh.

</h3>

<h3>

<ul>

<li>Districts<i> - 32</i>

<li>Capital City<i> - Chennai</i>

<li>Largest City<i> - Chennai</i>


<li>Governor<i> - BanwarilalPurohit</i>

<li>Chief Minister<i> - M. K. Stalin</i>

<li>Population<i> - 72,138,958</i>

<li>Tourist spots<i> - Mamallapuran, Ooty, Kodaikanal, Marina,

MuduraiMeenakshi Amman Temple, Thanjavur etc.,</i>

</ul>

<a href="Home.html">back</a>

</body>

</html>

OUTPUT:
RESULT:

Thus the web page is created and the image is embedded with hot spot and the linking
successfully and the output is verified.
Ex:02 Creating Website using CSS

Date:
Aim

To create a web site for our college using HTML and CSS.

Program

Step 1: Create a html file using simple construct

Step 2: Create your HTML structure.

Step 3:Create your CSS files for different style

Step 4:Link your CSS files to your HTML document using the <link> element.

Step 5:Create a user interface element (e.g., a button) to trigger the style switch.

Step 6:Write a JavaScript function to toggle between different stylesheets by changing the
href attribute of the linked CSS file.
Step 7:Test and deploy your HTML document with the style-switching mechanism.

Step 8:Optionally, enhance the mechanism with features like user preference storage or more
stylesheets.

Ex2.html

<html>

<head>

<title>A.V.C.C.E.</title>

<!--Extended Style Sheet -->

<link rel="stylesheet" type="text/css" href="newcss.css">

<!-- Embed Style Sheet-->

<style type="text/css">

p{

background-color: lightgrey;

text-align: justify;

margin: 2em 7em;


}

</style>

</head>

<body id="body">

<h1>A.V.C. COLLEGE OF ENGINEERING, MANNAMPANDAL</h1>

<p>

<span style="font: 200 x-large fantasy">ABOUT US</span><BR>

A.V.C. College of Engineering was started in the year 1996 committed to social welfare. The founding
father Sri S. Ramalingam Pillai sowed the seeds of A.V. Charities in 1806 in memory of his beloved
son Thiru Velayutham pillai. A.V. Charities began its educational services by starting the A.V.C.
(Autonomous) college in 1955, extended their horizon to A.V.C Polytechnic in 1983 and in 1996 by
opening the Engineering college. A.V. Charities serve as Beacon light in the field of education to the
innumerable youth, with rural background. We are very glad to say that we are second to none in
enhancing the young minds to compete the ever changing global changes.

A.V.C. College of Engineering is a pioneer institution and first self financing college in Nagapattinam
District. We have been approved by All India Council for Technical Education (AICTE) and also in
possession of ISO 9001:2015 certificate. We are moving ahead with National Board of Accreditation
(NBA) for the Engineering courses. Our Mission is to make the institution a Centre of Academic
Excellence. The R&D facilities have been opened up to make the students as reservoir of knowledge,
aptitude to advance and to face the global challenges.

</p>

<!-- Inline Sytle Sheet-->

<table style="background-position: center;text-align: center;padding: 3px;">

<tr>

<td align="left">

<div class="div">

<ul>

<lh>DEPARTMENTS</lh>

<li><a href="cse.html">CSE</a></li>

<li><a href="ece.html">ECE</a></li>

</ul>
</div>

</td>

</tr>

</table>

</body>

</html>

Cse.html

<html>

<head>

<title>CSE</title>

</head>

<body>

<h1>COMPUTER SCIENCE AND ENGINEERING</h1>

<div class="row hidden-sm hidden-xs" style="margin-left:200px";>

<h3> <b>VISION</b></h3>

<p>To excel in the field of Computer Science and Engineering with technological
innovations.</p>

<h3><b>MISSION</b></h3>

<p> 1. To impart quality technical education to the students through creative teaching learning
process.<br>

2.To create facilities and expertise in cutting-edge computer technologies through Industry
Institute partnership.<br>

3. To motivate the students to apply their innovative ideas to construct research models.<br>

4. To transform the students into socially and ethically responsible professionals.<br></p>

</div>

</body>

</html>

Ece.html

<html>
<head>

<title>CSE</title>

</head>

<body>

<h1>COMPUTER SCIENCE AND ENGINEERING</h1> <div>

<h3><b>VISION</b></h3>

<P> To produce professional technocrat in Electronics and Communication Engineering to face


the demands of industrial developments and benefits of the mankind.

</P>

<h3><b>MISSION</b></h3>

<P><ol type="1">

<li>To contribute knowledge in fundamentals and applied areas of Electronics and Communication
Engineering</li>

<li>To implement theoretical concepts in practical scenarios</li>

<li>To carry out project works through constant interaction with industry</li>

<li>To provide ethical and value based education to serve societal needs</li>

</ol></P>

</div>

</body>

</html>
Result:

Thus the HTML program for creating websites using different style sheets was executed
successfully.
Ex:03 Validating Web Form Controls using DHTML

Date:

Aim

To write a DHTML program to validate web form controls for Client side
script.

Algorithm:
Step 1: Write a Html program for accepting basic information like Name,Password etc.,

Step 2:Now write a javascript program to get these information and do some basic evaluation
like name not null,password confirmation.,

Step 3:Pass the values to the JavaScript and evaluate the information

Step 4:Add CSS to style the webpage and use alert to show the error.

Program:
Userlogin.html

<html>

<head>

<SCRIPT LANGUAGE="JAVASCRIPT">

function essentials_of_validation(form1)

var return_value=true;

var username=form1.txtusername.value;

var password1=form1.txtpassword1.value;

var password2=form1.txtpassword2.value;

if(username.length < 8)

return_value=false;

window.alert("user name less thn 8 chars");

}
if(password1.length<6)

return_value=false;

window.alert(" pwd should be > 6 char's ");

form1.txtpassword1.value="";

form1.txtpassword2.value="";

if(password1!=password2)

return_value=false;

window.alert("ur password mismatched ");

form1.txtpassword1.value="";

form1.txtpassword2.value="";

return return_value;

</script>

</head>

<body bgcolor="skyblue">

<marquee><b><u><font face="comic sans ms" color="light blue">login

here</font></u></b></marquee>

<form name="form1" onSubmit="essentials_of_validation(this)">

Username <input type="text" name="txtusername" size=20>

<br>Password: <input type="password" name="txtpassword1" size=20>

<br>Confirm password:<input type="password" name="txtpassword2" size=20>

<br><br>

<input type="submit" value="submit">


<input type="reset" value="reset">

</form>

</body>

</html>

Output:
Result:
Thus the HTML program for evaluating the web form controls was executed successfully.
Ex:04 Installing Apache Tomcat in Windows
Date:

Step 1: We need to first install the Tomcat 10 zip file from this website. On the website,
select the 64-bit Windows zip (PGP, sha512) in the Core section to start the download
process for the Tomcat zip file.

Step 2: Check If JDK Is Installed. Open Command Prompt and enter the following
commands
$ java -version
$ javac –version

If JDK is not installed on your computer, install JDK. In the above picture, we can see JDK is
already installed on our computer.
Step 3: Unzip Tomcat 10 Zip File. Go to the location where you have downloaded the
Tomcat 10 zip file. Right-click on the Apache tomcat file place the cursor on 7-Zip and click
on Extract Here to extract the folder.

Step 4: Creating JAVA_HOME Variable. Click Start then in the search bar, search for “Edit
the system environment variables” and click on it. The following System Properties box will
open. Select Environment Variables in the box.
On clicking Environment Variables the following box will open.

Step 5: We have to create a JAVA_HOME variable and insert the path of the JDK file stored
in our computer, which will be shown below. So select New from the System variables in the
above picture. A New System Variable box will be opened where we will have to fill in the
Variable name and Variable value.
Step 6: Go to the location where you have stored the contents of the JDK file in My
Computer or PC. Copy the root path of the location of the JDK file as shown below.

Step 7: Paste the JDK path from the above picture into the Variable value field and in the
Variable name field, give the name JAVA_HOME as shown below.
Step 8: Check the Working of Tomcat. Open the extracted apache tomcat file. We will see
all the following files in them. Among them open the batch file named “startup”.

Step 9: Check if the Startup Windows Batch File is running properly.


By default, the server port number is 8080.

Step 10: Successful Installation of Tomcat. Our next step is to open an internet browser like
Google and type in the address
http://localhost:8080

Then click enter and the following browser will appear suggesting the successful installation
of Apache Tomcat.
Result:
Thus the Apache Tomcat server was installed successfully.
Ex:05(A) Invoking Servlets from HTML forms

Date:
Aim:

To write a java program to invoke servlets from HTML form.

Procedure:

index.html:

(1) Create a web page using HTML form that contains the fields such as
label,text and one submit button.

(2) Set the URL of the server as the value of form’s action attribute.

(3) Run the HTML program.

(4) Submit the form data to the server.

welcome.java:

(1) Define the class server that extends the property of the class
GenericServlet.

(2) Handle the request from the client by using the method service() of
GenericServlet class.

(3) Get the parameter names from the HTML form by using the method
getParameterNames().

(4) Get the parameter values from the HTML forms by using the method
getParameter().

(5) Send the response to the client by using the method of PrintWriter class
Program:

Index.html

<html>

<head>

<title>Getting values from form</title>

</head>

<body>

<form action="welcome" method="get">

User Name:<input type="text" name="uname"><br>

<input type="submit" value="Submit">

</form>

</body>

</html>

Welcome.java

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class welcome extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/html;charset=UTF-8");

try (PrintWriter out = response.getWriter()) {

String username=request.getParameter("uname");

out.println("Welcome "+username);

} }

}
OUTPUT:

Result:

Thus, the invocation of servlet from HTML from has been developed successfully
Ex:5(B) Session Tracking

Date:
Aim:

To perform session tracking using hidden form fields using servlet.

Procedure:

1. Create a html file which contains user information.

2. The first servlet will receive these values.

3. First servlet stores them in the hidden form fields.

4. The second servlet will display the user information with greeting message.

Program:

Index.html

<html>

<head>

<title>Session Tracking using Hidden form fields</title>

</head>

<body>

<form action="ser1">

Enter the Name:<input type="text" name="uname"><br>

Enter the City:<input type="text" name="city"><br>

<input type="submit" value="Submit">

</form>

</body>

</html>

Ser1.java

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class ser1 extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/html;charset=UTF-8");

try (PrintWriter out = response.getWriter()) {

String n=request.getParameter("uname");

String c=request.getParameter("city");

out.println("<form action=serv2>");

out.println("<input type='hidden' name='uname' value="+n+" >");

out.println("<input type='hidden' name='city' value="+c+" >");

out.println("<input type='submit' value='Just Click here'>");

serv2.java

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class serv2 extends HttpServlet {


protected void processRequest(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/html;charset=UTF-8");

try (PrintWriter out = response.getWriter()) {

String n=request.getParameter("uname");

String c=request.getParameter("city");

out.println("Hello "+n+"<br>");

out.println("Your city is "+c);

Output
Result:

Thus, the Java Program for Session Tracking Using Hidden Form Fields has been executed
successfully.
Ex:06 Conducting Online Examination Using JSP
Date:

Aim:

To create the JSP program for conducting online examination for displaying mark list.

Algorithm:

1. Start the program.


2. With the scriplet tag, include information like document Created on and author.
3. Set the content type using page content type=”txt\html”.
4. Include the doctype with transitional flavour.
5. Get the input as regno , name and store in the table.
6. Create the forms as exam and index.
7. Click the submit button, after completing all the questions. If the answers are
correct it will display as correct else incorrect.
8. Stop the program.

Program:

Newjsp.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Examination Panel</title>
</head>
<body bgcolor="cyan">
<%@ page language="java" %>
<%@ page import ="java.sql.*" %>
<%
String reg= request.getParameter("txt_reg");
String name = request.getParameter("txt_name");
out.println("<h2>Welcome" + name + "...Your Register number is " + reg +
"!!</h2><br><br><br>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sTable = "exam";
String sSql = "SELECT * FROM " + sTable + "";
String database = "jdbc:odbc:sDBQ";
Connection cn = null;
Statement st = null;
ResultSet rs = null;
try {
cn = DriverManager.getConnection( database ,"sa","");
st = cn.createStatement();
rs = st.executeQuery( sSql );
ResultSetMetaData rsmd = rs.getMetaData();
String s1,s2,s3,s4;
int i=1;
while(rs.next())
{
out.println("<form name='exam' action='newjsp2.jsp' method='post'><b>"+i+"
."+
rs.getString(1) + "</b><br><br>");
s1 = rs.getString(2);
s2 = rs.getString(3);
s3 = rs.getString(4);
s4 = rs.getString(5);
out.println("<input type=radio name=opt"+i+" value="+s1+" CHECKED>"+
s1 +" <br><br>");
out.println("<input type=radio name=opt"+i+" value="+s2+">" + s2
+"<br><br>");
out.println("<input type=radio name=opt"+i+" value="+s3+">" + s3
+"<br><br>");
out.println("<input type=radio name=opt"+i+" value="+s4+">" + s4
+"<br><br>");
i++;
}
out.println("<input name ='submit' value='Submit' type='submit'/>");
/*int n = rsmd.getColumnCount();
out.println( "<table border=1 cellspacing=3><tr>" );
for( int i=1; i<=n; i++ ) // Achtung: erste Spalte mit 1 statt 0
out.println( "<th>" + rsmd.getColumnName( i ) + "</th>" );
while( rs.next() )
{out.println( "</tr><tr>" );
for( int i=1; i<=n; i++ ) // Achtung: erste Spalte mit 1 statt 0
o ut.println( "<td nowrap>" + rs.getString( i ) + "</td>" );
}
out.println( "</tr></table>" );*/
}finally {
try { if( null != rs ) rs.close(); } catch( Exception ex ) {}
try { if( null != st ) st.close(); } catch( Exception ex ) {}
try { if( null != cn ) cn.close(); } catch( Exception ex ) {}
}
%>
</body>
</html>

Newjsp1.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome to Online Examination</title>
</head>
<body bgcolor="cyan">
<form name="index" action="newjsp.jsp" method="post">
<center><h1><span><font color="red">Welcome to Online
Examination</font></span></h1>
<br>
<h2><u><span><font color="blue">Instructions to the
Candidates</font></span></u></h2>
<br><h3><ol><li>Fill the correct Registration number.</li>
<br><li>Enter your name.</li>
<br><li>Read the questions carefully.</li>
<br><li>No negative marking.</li></ol></h3>
<br>
<b>Enter your Register number</b>
<input type="text" name="txt_reg">
<b>Enter your Name</b>
<input type="text" name="txt_name"><br><br>
<input name ="submit" value="Submit" type="submit"/>
</center>
</form>
</body>
</html>

Newjsp2.jsp

<%@page import="com.sun.java.swing.plaf.windows.resources.windows_es"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Exam Report</title>
</head>
<body bgcolor="cyan">
<center><h1>Your Report Card</h1></center>
<%@ page language="java" %>
<%@ page import ="java.sql.*" %>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sTable = "exam";
String sSql = "SELECT * FROM " + sTable + "";
String database = "jdbc:odbc:sDBQ";
Connection cn = null;
Statement st = null;
ResultSet rs = null;
try {
cn = DriverManager.getConnection( database ,"sa","");
st = cn.createStatement();
rs = st.executeQuery( sSql );
ResultSetMetaData rsmd = rs.getMetaData();
String s1,s2,s3,s4;
int i=1;
int correct=0,incorrect=0,total=0;
out.println("<h2><br><br><center><table border=1 cellpadding=2
cellspacing=2><tr><th>Question</th><th>Your Answer</th><th>Correct
Answer</th><th>Status</th></tr>");
while(rs.next())
{
total++;
s1 = rs.getString(1);
s2 = request.getParameter("opt"+i);
s3 = rs.getString(6);
if(s2.equals(s3))
{ s4="Correct";
correct++;
}
else
{ s4="Incorrect";
incorrect++;
}
out.println("<tr><td>"+s1+"</td><td>"+s2+"</td><td>"+s3+"</
td><td>"+s4+"</td></tr>");
i++;
}
out.println("</table><br><br><table><b><tr><td>Correct
Answers</td><td>"+correct+"</td></tr>");
out.println("<tr><td>Incorrect Answers</td><td>"+incorrect+"</td></tr>");
out.println("<tr><td>Total
Questions</td><td>"+total+"</td></tr></table></b></center></h2>");
}
finally {
try { if( null != rs ) rs.close(); }
catch( Exception ex ) {}
try { if( null != st ) st.close(); }
catch( Exception ex ) {}
try { if( null != cn ) cn.close(); }
catch( Exception ex ) {}
}
%>
</body>
</html>
Output:
Result:
Thus the JSP program for online examination was executed by connecting the
SQLSERVER and result was verified.
Ex:07(A) XML Schema and Referencing

Date:

Aim:

To define a XML schema and reference it in an XML document.

Algorithm:

Step 1: Start the program

Step 2: Define the schema for the xml document.

Step 3:Create a XML document with the same structure.

Step 4:Evalute the XML document with the parser.

Program:

Schema:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="library">

<xs:complexType> <xs:sequence>

<xs:element name="book" maxOccurs="unbounded">


<xs:complexType>

<xs:sequence>

<xs:element name="title" type="xs:string"/>

<xs:element name="author" type="xs:string"/>

<xs:element name="publication_year" type="xs:integer"/>

</xs:sequence>

</xs:complexType>

</xs:element>
</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>

XML:

<?xml version="1.0" encoding="UTF-8"?>

<library>

<book>

<title>The Catcher in the Rye</title>

<author>J.D. Salinger</author>

<publication_year>1951</publication_year>

</book>

<book>

<title>To Kill a Mockingbird</title>

<author>Harper Lee</author>

<publication_year>1960</publication_year>

</book>

<book>

<title>1984</title>

<author>George Orwell</author>

<publication_year>1949</publication_year>

</book>

</library>
Output:

Result:
Thus the XML schema was created and referred in an external xml document.
Ex:07(B) Online Application for Students using XML and XSL

Date:
Aim:

To develop an Online Applications for displaying student’s mark list using XML AND XSL.

Algorithm:

Step 1: Start the program.

Step 2: Create Stud.xml for storing student’s marks.

Step 3: Create an xsl for getting the marks from the xml.

Step 4: Run the application in the IDE.

Step 5: The student’s mark list for the corresponding register number will be displayed.

Step 6: Stop the program.

Stud.xml

<?xml version = "1.0"?>

<?xml-stylesheet type = "text/xsl" href = "students.xsl"?>

<class>

<student rollno = "101">

<name>Ram</name>

<marks>85</marks>

</student>

<student rollno = "102">

<name>Madhu</name>

<marks>95</marks>

</student>

<student rollno = "103">

<name>Arun</name>

<marks>90</marks>

</student>
<student rollno = "104">

<name>Kumar</name>

<marks>75</marks>

</student>

<student rollno = "105">

<name>Vinoth</name>

<marks>50</marks>

</student>

<student rollno = "106">

<name>Jenni</name>

<marks>98</marks>

</student>

<student rollno = "107">

<name>Priya</name>

<marks>95</marks>

</student>

<student rollno = "108">

<name>Parkshidha</name>

<marks>100</marks>

</student>

<student rollno = "109">

<name>Sreeji</name>

<marks>80</marks>

</student>

<student rollno = "110">

<name>Latha</name>

<marks>93</marks>
</student>

</class>

students.xsl

<?xml version = "1.0" encoding = "UTF-8"?>

<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">

<xsl:template match = "/">

<html>

<body>

<h2>Students</h2>

<table border = "1">

<tr bgcolor = "#9acd32">

<th>Roll No</th>

<th>Name</th>

<th>Marks</th>

</tr>

<xsl:for-each select="class/student">

<tr>

<td><xsl:value-of select = "@rollno"/></td>

<td><xsl:value-of select = "name"/></td>

<td><xsl:value-of select = "marks"/></td>

</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>
Output:

RESULT:

Thus the application to get the marks of the students using xml and xsl was successfully executed.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy