69
USN: 2VX13MCA14 SUBJECT CODE:13MCA18 1. Create an XHTML page to demonstrate the usage of a. Text formatting tags b. Links c. Images d. Tables SOURCE CODE <? xml version="1.0" encoding="utf-8" ?> <! DOCOTYPE html PUBLIC "-//f2z//DTD XHTML 1.1//EN" "http://www.wwe.com/TR/xhtml 111/DTD/xhtml 11.dtd"> <html xmlns="http://www.wwe.com/1999/xhtml"> <head> <title>Text formatting, links, image, table</title> </head> <a href="6a.html"> click here for link </a> <body> <image src="Koala.jpg" height="80" width="80"> <p><h2>Formatting tags</h2><br> <h2>Italic: <i>This is in italic</i></h2><br> <h3>Bold: <b>This is in Bold</b></h3><br> <h4>Underline: <u>This is in underlined</u></h4><br></p> <table border="border"> <caption>Department of PG studies</caption> <tr> <th></th> <th>MBA</th> <th>MCA</th> MCA Department of P.G Studies, VTU, Belgaum Page no.

USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

Embed Size (px)

Citation preview

Page 1: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

1. Create an XHTML page to demonstrate the usage ofa. Text formatting tagsb. Linksc. Imagesd. Tables

SOURCE CODE<? xml version="1.0" encoding="utf-8" ?><! DOCOTYPE html PUBLIC "-//f2z//DTD XHTML 1.1//EN""http://www.wwe.com/TR/xhtml 111/DTD/xhtml 11.dtd"><html xmlns="http://www.wwe.com/1999/xhtml"><head><title>Text formatting, links, image, table</title></head><a href="6a.html"> click here for link </a><body><image src="Koala.jpg" height="80" width="80"><p><h2>Formatting tags</h2><br><h2>Italic: <i>This is in italic</i></h2><br><h3>Bold: <b>This is in Bold</b></h3><br><h4>Underline: <u>This is in underlined</u></h4><br></p><table border="border"><caption>Department of PG studies</caption><tr><th></th><th>MBA</th><th>MCA</th><th>M.Tech</th></tr><tr><th>Boys</th><td>30</td><td>25</td><td>35</td></tr><tr>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 2: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

<th>Girls</th><td>20</td><td>23</td><td>40</td></tr></html></body>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 3: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 4: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

2. Develop and demonstrate the usage of inline and external style sheet using css

SOURCE CODE<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//w3c//DTD XHTML 1.1//EN" "http://www.wwe.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http:wwe.org/1999/xhtml">

<link rel="stylesheet" type="text/css" href="vt1313.css"/><head><title>Usages of Inline & External style sheet using CSS</title></head><body><h1 class="major"> Welcome to VTU JnanaSangama</h1><p class="minor"> VTU is one of the top and best university. It has three departments, ie MCA, M-tech, MBA.</p>

<p class="minor", style="color:red"> Nearly 192 colleges are affiliated to VTU university. It has fast growing process

all over the colleges. It can be said that, VTU university is one of the best reputed university.</p>

<p class="minor"> Nearly 192 colleges are affiliated to VTU university. It has fast growing process all over the

colleges. It can be said that, VTU university is one of the best reputed university.</p>

<h3 class="pree"><u> Department of MCA </u></h3><ul style="color:red"><li> MCA </li><li> M-tech </li><li> MBA </li></ul></body></html><style> .pree

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 5: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

{color:red;

}

</style>

h1.major{

font-size:25pt;font-family:'algerian';font-style:bold;text-align:center;text-indent:0.5in;color:black;background-color:blue;

}p.minor

{font-size:15pt;font-family:'algerian';font-style:bold;text-align:left;text-indent:1.5in;color:blue;background-color:yellow;

}

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 6: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 7: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

3. Develop and demonstrate a XHTML that includes JavaScript for the followingproblems:a. Input: A number n obtained using promptOutput:The first n fibonacci series

SOURCE CODE<?xml version="1.0" encoding="utf-8"?><?DOCTYPE html PUBLIC "=//ww.w3.org//1999/TR/xhtml 11/DTD/xhtml11.dtd"><html xmlns="http://w3.org/1999/xhtml"><head><title>fiboncci series</title></head><body><h1> calculating Fibonacci numbers </h1><script type="text/javascript">n=prompt("Enter a number")

varn,a=0,b=1,i,c;if(n<0) alert("Invalid no")else{

if(n==1) document.write(a)else

document.write(a+"<br/>"+b)for(i=2;i<=n;i++){ c=a+b a=b b=cdocument.write("<br/>"+c)}

}</script></body></html>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 8: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 9: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

3 b. Input: A number n obtained using promptOutput: A table of numbers from 1 to n and their squares using alert

SOURCE CODE<?xml version="1.0" encoding="utf-8"?><?DOCTYPE html PUBLIC "=//ww.w3.org//1999/TR/xhtml 11/DTD/xhtml11.dtd"><html xmlns="http://w3.org/1999/xhtml"><head><title>squre of a number</title></head><body><h1> calculating square of numbers </h1><script type="text/javascript">varn,i,b;n=prompt("Enter a number")if(n<=0) alert("Invalid number")else{

for(i=1;i<=n;i++){

document.write(i,"*",i,"=")b=i*i;document.write(b,"<br/>")

}}</script></body></html>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 10: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 11: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

4. Develop and demonstrate using JavaScript, a XHTML document that displays random numbers (integers).

SOURCE CODE<?sxml version="1.0" encoding="utf-8" ?><! DOCOTYPE html PUBLIC "-//f2z//DTD XHTML 1.1//EN""http://www.wwe.com/TR/xhtml 111/DTD/xhtml 11.dtd"><html xmlns="http://www.wwe.com/1999/xhtml"><head><title>Random numbers </title></head><body><p id="demo">Click the button to display the random number between 1 to 10</p>

<button onclick="fun()">Try it</button>

<script>function fun() {var x=document.getElementById("demo")x.innerHTML=Math.floor((Math.random()*10)+1); }</script></body></html>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 12: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 13: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

5 a. Develop and demonstrate , using javascript a XHTML document that collects the USN (The valid format is: A digit from 1 to 4 followed by two upper case characters followed by two digits followed by two upper-case characters followed by three digits; no embedded spaces are allowed) of the user. Event handler must be included for the form element that collects this information to validate the input.Messages must be produced when errors are detected.

SOURCE CODE<?xml version="1.0" encoding="utf-8"?><?DOCTYPE html PUBLIC "=//ww.w3.org//1999/TR/xhtml 11/DTD/xhtml11.dtd"><html xmlns="http://w3.org/1999/xhtml"><head><title> Student USN</title></head><h1> Validating student USN</h1><body><center><script type="text/javascript">functionfunc(usn){

var pattern1=/^[1-4][A-Z]{2}[0-9]{2}[A-Z]{2}[0-9]{3}$/ if (!usn.value.match(pattern1)||usn.value.length==0) {

alert(" Invalid usn");return false;

}elsealert("usn valid !");

}</script><form action=" "><p>USN: <input type= "text" name= "usn" /><br /><input type= "button" value= "validate" onclick="func(usn)" /></p></form></center></body></html>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 14: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 15: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

5 b. Modify the 5a program to get the current semester also(restricted to be a number from 1 to 6)

SOURCE CODE<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>USN and Semester Validation</title></head><body><center><script type="text/javascript">functionfunc(usn,sem){

var pattern1=/^[1-4][A-Z]{2}[0-9]{2}[A-Z]{2}[0-9]{3}$/if(!usn.value.match(pattern1)||usn.value.length==0){

alert ("Invalid USN!\nEnter a valid USN")return false

}else alert("USN valid!")var pattern2=/^[1-6]$/if(!sem.value.match(pattern2)||sem.value.length==0){

alert("Invalid Semester!\nEnter a valid Semester")return false

}else alert("Semester valid!")

}</script><form action=" "><p>USN:&nbsp&nbsp&nbsp<input type="text" name="usn" /><br/><br/>Semester: <input type="text" name="sem"/><br/><br/><input type="button" value="Validate" onclick="func(usn,sem)" /></p></form>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 16: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

</center></body></html>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 17: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 18: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 19: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

6 a. Develop and demonstrate using javascript script, a XHTML document that contains three images, stacked on top of each other, with only enough of each showing so that the mouse cursor can be placed over a sime part of them . When the cursor is placed over the exposed part of any paragraph, it should rise to the top to become completely visible

SOURCE CODE<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC"-//w3c//DTD xhtml 1.1//EN""http://www.w3.org/tr/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Stack Layers</title><style>p{

position:absolute;text-align: center;border: solid thick black;padding: 2em;width: 400px;

top:25px;right:25px;

}.para1{

background-color:green;top:100px;left:300px;

}.para2{

background-color:pink;top:120px;left:320px;

}.para3{

background-color:yellow;top:140px;left:340px;

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 20: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

}</style><script>val=0;function pull(obj,inc){

val=val+inc;obj.style.zIndex=val;

}</script></head><body bgcolor="white"><p class="para1" onmouseover="pull(this,1)">First Para</p><p class="para2" onmouseover="pull(this,1)">Second Para</p><p class="para3" onmouseover="pull(this,1)">Third Para</p></body></html>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 21: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 22: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

6 b. Modify the above (6a) document so that when an image is moved from the top stacking position it returns to its original position rather then to the bottom

SOURCE CODE<?xml version="1.0"?><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Stack Layers</title><style>p{

position:absolute;text-align: center;border: solid thick black;padding: 2em;width: 400px;

}.para1{

background-color:green;top:100px;left:300px;

}.para2{

background-color:pink;top:120px;left:320px;

}.para3{

background-color:yellow;top:140px;left:340px;

}</style><script>val=0;function pull(obj,inc){

val=val+inc;obj.style.zIndex=val;

}</script>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 23: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

</head><p class="para1" onmouseover="pull(this,1)" onmouseout="pull(this,-1)">First Para</p><p class="para2" onmouseover="pull(this,1)" onmouseout="pull(this,-1)">Second Para</p><p class="para3" onmouseover="pull(this,1)" onmouseout="pull(this,-1)">Third Para</p></body></html>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 24: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 25: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

7. Develop using java script, an XHTML documents that use of on load and on focus events.

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 26: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

SOURCE CODE<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC"_//W3C//DTD/XHTML1.1//EN""http://www.w3.org/TR/XHTML11/DTD/XHTML11.dtd"/>

<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Onload_Onfocus_Events</title><script type="text/javascript" src="style.js"></script></head><body onload="chkphone();"><h2>Customer Info</h2><form action =" "><p><input type="text" id="phone" />Phone </label><input type="reset" id="reset" /><input type="submit" id="submit" /></p></form><script>document.getElementById("phone").onchange=chkphone;</script></body></html>

Style.js

functionchkphone(){ varmyphone=document.getElementById("phone");varpos=myphone.value.search(/^\d{3}-\d{3}-\d{4}$/)if(pos !=0) {alert("Invalid")

myphone.focus();myphone.select();

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 27: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

return false; }else {alert("Valid")myphone.select();myphone.focus();return true; }}

OUTPUT 1:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 28: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

OUTPUT 2:

8a. Design an XML document to store information about a student in an engineering college affiliatd to vtu the information must include usn name

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 29: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

name of the college branch year of joining and e-mail id. Make up sample data data for 3 students .Create a css style sheet and use it to display the document.

SOURCE CODE<?xml version="1.0" encoding="utf-8"?><?xml-stylesheethref="Info.css" type="text/css"?><student><stud-info>Student Information</stud-info><stud1>

<usn>USN: 2VX13MCA06</usn><name>Name: BahubaliUgare</name><noc>College: VTU</noc><branch>Branch: MCA</branch><yoj>Year: 2013</yoj><eid>Email: [email protected]</eid>

</stud1><br/><stud2>

<usn>USN: 2VX13MCA19</usn><name>Name: BannuPatil</name><noc>College: VTU</noc><branch>Branch: MCA</branch><yoj>Year: 2013</yoj><eid>Email: [email protected]</eid></stud2>

<br/><stud3>

<usn>USN: 2VX13MCA07</usn><name>Name:Manjunath A</name><noc>College: VTU</noc><branch>Branch: MCA</branch><yoj>Year: 2013</yoj><eid>Email: [email protected]</eid>

</stud3></student>

Info.css

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 30: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

stud-info { display:block; color:blue; font-style:italic; font-size:200%; }student { display:block; font-size:100%; }stud1 { display:block; color:blue; }stud2 { display:block; color:red; }stud3 { display:block; color:brown; } usn,name,noc,branch,yoj,eid { display:block; }

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 31: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

8b. Create an XSLT style sheet for one student element of the above document and use it to create a display of that element.

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 32: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

SOURCE CODE<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="lab8b.xsl"?><studinfo><student><usn>2VX11MCA01</usn><name>Bahubali</name><college>VTU BGM</college><branch>MCA</branch><year>2013 </year><email>[email protected]</email></student></studinfo>

lab8b.xsl

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

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns="http://www.w3.org/1999/xhtml"><xsl:template match="student"><html><body><span style="color:red;font-size:20pt"><xsl:value-of

select="usn"/></span><br/><span style="color:green;font-family:agency FB;font-size:25"><xsl:value-of select ="name"/></span><br/><span style="color:blue"><xsl:value-of select="college"/></span><br/><span style="color:gray"><xsl:value-of select="branch"/></span><br/><span style="color:brown"><xsl:value-of select="year"/></span><br/>

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 33: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

<span style="font-style:italic"><xsl:value-of select="email"/></span><br/><br/>

</body></html></xsl:template></xsl:stylesheet>

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 34: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

9. Write a Perl program which demonstrates the usage of scalar variables and arrays

SOURCE CODE MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 35: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

9.html

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> scalar variables and arrays </title>

</head>

<body>

<form method="get" action="http://localhost/cgi-bin/9.pl">

<h1> Demonstrate scalar variables and arrays</h1>

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

</form>

</body>

</html>

9.pl

#!c:/xampp/perl/bin/perl.exe

useCGI':standard';

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 36: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

print "content-type:text/html","\n\n";

print "<html><body>";

print "<br>","server name:",$ENV{'SERVER_NAME'};

print "<br>","server software :",$ENV{'SERVER_SOFTWARE'};

print "<br>","server protocol:",$ENV{'SERVER_PROTOCOL'};

print "<br>","cgi revision:",$ENV{'GATEWAY_INTERFACE'};

print "</body></html>";

exit(0);

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 37: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

10. Write a Perl program to display various Server information like Server Name, Server Software, Server protocol,CGI Revision etc.

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 38: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

SOURCE CODE

pgm10.html

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> About this server </title>

</head>

<body>

<form method="get" action="http://localhost/cgi-bin/pgm10.pl">

<h1> Click on enter to see the server information </h1>

<br>

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

</form></body>

</html>

pgm10.pl

#!c:/xampp/Perl/bin/perl.exe

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 39: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

useCGI':standard';

print "content-type:text/html","\n\n";

print "<html><body>";

print "<br>","server name:",$ENV{'SERVER_NAME'};

print "<br>","server software :",$ENV{'SERVER_SOFTWARE'};

print "<br>","server protocol:",$ENV{'SERVER_PROTOCOL'};

print "<br>","cgi revision:",$ENV{'GATEWAY_INTERFACE'};

print "</body></html>";

exit(0);

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 40: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

11. Write a Perl program to display a digital clock which displays the current time of the server

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 41: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

SOURCE CODE

pgm11.html

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> Digital clock </title>

<body>

<form method="get" action="http://localhost/cgi-bin/pgm11.pl">

<hr><br><br>

<h3> Click on submit to see the time </h3>

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

</form>

</body>

</html>

pgm11.pl

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 42: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

#!c:/xampp/perl/bin/perl.exe

print "refresh:1

url=http://localhost/cgi-bin/pgm11.pl","\n";

print "content-type:text/html","\n\n";

print "<html>", "<body>", "<h1> The current time is....</h1>","\n";

($sec,$min,$hour)=localtime(time);

$ampm="am";

if($hour>12)

{

$hour -= 12;

$ampm="pm";

if($hour==0)

{

$hour=12;

}

}

printf("$hour:$min:$sec $ampm");

print"</body></html>";

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 43: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

12. Write a Perl program to accept the User Name and display a greeting message randomly chosen from a list of 4 greeting messages.

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 44: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

SOURCE CODE

pgm12.html

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> Greeting </title>

</head>

<body>

<form method="post" action="http://localhost/cgi-bin/pgm12.pl">

<h1> Enter your name</h1>

<br>

<input type="text"

name="yourname"><br><br>

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

</form>

</body>

</html>

pgm12.pl

#!c:/xampp/Perl/bin/perl.exe

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 45: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

use CGI ':standard';

print "content-type:text/html","\n\n";

$name=param('yourname')|| 'abcd';

my $range=4;

my $random_number=int(rand($range));

print"$random_number \n";

if($random_number==0)

{

print("Hello $name, welcome to Perl programming");

}

if($random_number==1)

{

print("Good evening $name, how are you?");

}

if($random_number==2)

{

print("Have a good day $name");

}

if($random_number==3)

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 46: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

{

print("Thank you $name, for using fedora");

}

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 47: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

13. Write a Perl program to keep track of the number of visitors visiting the web page and todisplay this count of visitors, with proper headings.

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 48: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

SOURCE CODE

13.html

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Run your first Perl script </title>

</head>

<body>

Click on <a href="http://localhost/cgi-bin/13.pl">this link </a>to run your first perl script.

</body>

</html>

13.pl

#!c:/xampp/perl/bin/perl.exe

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 49: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

#KEEPING COUNT OF VISITORS IN A FILE

useCGI':standard';

print"content-type:text/html\n\n";

#opening filein read mode

open(FILE,"<count.dat");

$cnt=<FILE>;

close(FILE);

$cnt=$cnt+1;

#opening file to write

open(FILE,">count.dat");

print FILE $cnt;

close(FILE);

print "The Number of times Visitor count is: $cnt";

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 50: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

14. Write a CGI-Perl program to use a cookie to remember the day of the last login from a user and display it when run

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 51: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

Source Code:

cookies.html

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> COOKIES program </title>

<body>

<form method="get" action="http://localhost/cgi-bin/cookies.pl">

<hr><br><br>

<h3> Click on submit to see the COOKies info </h3>

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

</form>

</body>

</html>

cookies.pl

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 52: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

#!c:/xampp/perl/bin/perl.exe

useCGI':standard';

#print "content-type:text/html","\n\n";

@last_day = cookie('last_time');

$day_of_week = (qw(Sunday Monday Tuesday Wednesday Thursday

Friday Saturday)) [(localtime)[6]];

$month = (qw(January February March April May June July

August September October November December))[(localtime)[4]];

$day_of_month = (localtime)[3];

@day_stuff = ($day_of_week,$month,$day_of_month);

$day_cookie = cookie(-name => 'last_time',

-value => \@day_stuff,

-expires => '+5d');

print header(-cookie => $day_cookie);

print "<html><body>";

if(scalar(@last_day) == 0)

{ print "welcome to you on your first visit to our site\n";

}

else

{

($day_of_week,$month,$day_of_month)= @last_day;

print "wel come back \n",

"your last visit was on ",

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 53: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

"$day_of_week,$month,$day_of_month";

}

print "</body></html>";

exit(0);

OUTPUT:

MCA Department of P.G Studies, VTU, Belgaum Page no.

Page 54: USN: 2VX13MCA14 SUBJECT CODE:13MCA18 ...hanumanthareddygn.weebly.com/.../wp_formatted_pgms.docx · Web viewUSN: 2VX13MCA14 SUBJECT CODE:13MCA18 MCA Department of P.G Studies, VTU,

USN: 2VX13MCA14 SUBJECT CODE:13MCA18

MCA Department of P.G Studies, VTU, Belgaum Page no.