web manual 27-11-09

Upload: jothi1083

Post on 08-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Web Manual 27-11-09

    1/53

    Develop and demonstrate a XHTML document that illustrates the

    use external style sheet, ordered list, table, borders, padding, color,

    and the tag.

    p,table,li, // mystyle.css{

    font-family: "lucida calligraphy", arial, 'sans serif';margin-left: 10pt;}

    p { word-spacing: 5px; }

    body { background-color:rgb(200,255,205); }

    p,li,td { font-size: 75%;}

    td { padding: 0.5cm; }

    th {text-align:center;font-size: 85%;

    }

    h1, h2, h3, hr {color:#483d8b;}

    table{border-style: outset;

    background-color: rgb(100,255,105);}

    li {list-style-type: lower-roman;}

    span{color:blue;background-color:pink;font-size: 29pt;font-style: italic;

    font-weight: bold;}

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    2/53

    Lab program1

    This header is 36 ptThis header is blue

    This paragraph has a left margin of 50 pixels

    Name Email

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    TSB Singh Prakash S manojKumar

    This is a text. This is a text. This is a text. This is a text. This is atext. This is a text. This is a text. This is a text. This is a text. This is atext.

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    3/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    4/53

    1. Develop and demonstrate a XHTML file that includes Javascript

    script for the following problems:

    a) Input: A number n obtained using prompt

    Output: The first n Fibonacci numbers

    var fib1=0,fib2=1,fib=0;var num = prompt("Enter a number : \n", "");

    if(num!=null && num>0){document.write("" + num + " Fibonocci are
    ");if(num==1)

    document.write(" "+ fib1 + "");else

    document.write("" + fib1 + "
    " + fib2 + "");

    for(i=3;i

  • 8/6/2019 Web Manual 27-11-09

    5/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    6/53

    2b) Input: A number n obtained using prompt

    Output: A table of numbers from 1 to n and their squares using

    alert

    var num = prompt("Enter a number : \n", "");if(num >0 && num !=null){msgstr="Number and its Squares are \n";for(i=1;i

  • 8/6/2019 Web Manual 27-11-09

    7/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    8/53

  • 8/6/2019 Web Manual 27-11-09

    9/53

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    10/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    11/53

    3b) Parameter: A number

    Output: The number with its digits in the reverse order.

    function disp(num){var alphaExp = /^[0-9]+$/;

    if(!num.value.match(alphaExp)){

    alert("Input should be positive numeric");return false;

    }var rn=0, n= Number(num.value);while(n!=0){r = n%10;n = Math.floor(n/10);rn = rn*10 + r;}alert("The " + num.value + " in reverse is " + rn);

    }

    Enter a number :

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    12/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    13/53

    3. a) Develop and demonstrate, using Javascript script, 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 allowed) of the user. Event handler must be

    included for the form element that collects this information tovalidate the input. Messages in the alert windows must be produced

    when errors are detected.

    function formValidator(){

    var usn = document.getElementById("req1");if(isCorrect(usn)){return true;

    }return false;

    }function isCorrect(elem1){var alphaExp1=/^[1-4][A-Z][A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9][0-9]$/

    if(elem1.value.length == 0)

    {alert("US Number is empty");

    elem1.focus();return false;

    }else if(!elem1.value.match(alphaExp1))

    {alert("US Number should be in DAADDAADDD format");

    elem1.focus();return false;

    }

    alert("US Number IS CORRECT");return true;

    }Enter your USN. in DAADDAADDD format :

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    14/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    15/53

    4.b) Modify the above program to get the current semester also

    (restricted to be a number from 1 to 8)

    function formValidator()

    { var usn = document.getElementById('req1');var sem = document.getElementById('req2');if(isCorrect(usn)){ if(isPerfect(sem))

    return true;}return false;

    }function isPerfect(elem2){ var alphaExp2 = / [1-8]$/

    if(elem2.value.length == 0)

    { alert("Semester Number is empty");elem2.focus();return false;

    }else if(!elem2.value.match(alphaExp2)){ alert("Invalid Semester Number");

    elem2.focus();return false;

    }alert("Semester Number IS CORRECT");return true;

    }function isCorrect(elem1){var alphaExp1 = /^[1-4][A-Z][A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9][0-9]$/

    if(elem1.value.length == 0){ alert("US Number is empty");

    elem1.focus();return false;

    }else if(!elem1.value.match(alphaExp1))

    { alert("US Number should be in DAADDAADDD format");elem1.focus();

    return false; }alert("US Number IS CORRECT");return true;

    }

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    16/53

    Enter your USN. in DUUDDUUDDD format :

    Enter your Sem. in D[1-8] format :

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    17/53

    5a) Develop and demonstrate using javascript Script, a XHTML

    document that contains three short paragraphs of text, stacked on top of

    each other, with only enough of each showing so that the mouse cursor

    can be placed over some part of them. When the cursor is placed over

    the exposed part of any paragraph, it should raise to the top to become

    completely visible.

    var top="c1";function vtop(newTop){domTop=document.getElementById(top).style;domNew=document.getElementById(newTop).style;

    domTop.zIndex=0;domNew.zIndex=10;top=newTop;}.pas1{position:absolute;

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    18/53

    top:0;left:0;z-index:0;border:3px dotted;background-color:red;}

    .pas2{position:absolute;top:30px;left:90px;z-index:0;border:3px dotted;background-color:green;}.pas3{

    position:absolute;top:60px;left:180px;z-index:0;border:3px dotted;background-color:blue;}Develop and demonstrate using javascript Script, a XHTML document that contains

    three short paragraphs of text, stacked on top of each other, with only enough of each

    showing so that the mouse cursor can be placed over some part of them. When the cursoris placed over the exposed part of any paragraph, it should raise to the top to become

    completely visible

    Develop and demonstrate, using Javascript script, a XHTML document that collects the

    USN ( the valid format is: A digit from 1 to 4 followed by two upper-case charactersfollowed by two digits followed by two upper-case characters followed by three digits; no

    embedded spaces allowed) of the user. Event handler must be included for the form

    element that collects this information to validate the input. Messages in the alert

    windows must be produced when errors are detected

    Develop and demonstrate, using Javascript script, 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 allowed) of the user. Event handler must be included for the form

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    19/53

    element that collects this information to validate the input. Messages in the alertwindows must be produced when errors are detected

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    20/53

    5 b) Modify the above document so that when a paragraph is moved

    from the top stacking position, it returns to its original position rather

    than to the bottom.

    var top="c1";

    function vtop(newTop){domTop=document.getElementById(top).style;domNew=document.getElementById(newTop).style;domTop.zIndex="0";domNew.zIndex="10";top=newTop;}

    .pas1{position:absolute;top:0;left:0;z-index:0;border:3px dotted;

    background-color:red;}.pas2{position:absolute;top:30px;left:90px;z-index:0;

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    21/53

    border:3px dotted;background-color:green;}.pas3{position:absolute;

    top:60px;left:180px;z-index:0;border:3px dotted;background-color:blue;}Develop and demonstrate using javascript Script, a XHTML document that contains

    three short paragraphs of text, stacked on top of each other, with only enough of eachshowing so that the mouse cursor can be placed over some part of them. When the cursor

    is placed over the exposed part of any paragraph, it should raise to the top to become

    completely visible

    Develop and demonstrate, using Javascript script, a XHTML document that collects theUSN ( 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 allowed) of the user. Event handler must be included for the formelement that collects this information to validate the input. Messages in the alert

    windows must be produced when errors are detected

    Develop and demonstrate, using Javascript script, 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; noembedded spaces allowed) of the user. Event handler must be included for the form

    element that collects this information to validate the input. Messages in the alert

    windows must be produced when errors are detected

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    22/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    23/53

    6a) Design an XML document to store information about a student in

    an engineering college affiliated to VTU. The information must include

    USN, Name, Name of the College, Brach, Year of Joining, and e-mail id.

    Make up sample data for 3 students. Create a CSS style sheet and use it

    to display the document.

    students> 4CI01CS018 KISHOR KUMAR CIT CSE

    2001 [email protected]

    4KV00CS023 DINESH KVGCE CSE 2000 [email protected]

    4KV03IS400 BALAPRADEEP KVGCE ISE 2003 [email protected]

    students

    {font-family:arial; color:red;font-size:16pt;}VTU{display:block;

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    24/53

    font-family:times new roman;color:blue;font-size:14pt;}USN{

    font-family:arial;color:green;font-size:12pt;}name{font-family:arial;color:blue;}college,branch,YOJ,email{

    display:block;font-family:arial;color:black;font-size:10pt;margin-left:20pt;}

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    25/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    26/53

    6b) Create an XSLT style sheet for one student element of the above

    document and use it to create a display of that element.

    4CI01CS018 KISHOR KUMAR CIT CSE 2001 [email protected]

    Style sheet for 6b.xml VTU Student Description USN:

    Name:
    College:
    Branch:
    Year of Join:


    E-Mail:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    27/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    28/53

    7 a) Write a Perl program to display various Server Information like

    Server Name, Server Software, Server protocol, CGI Revision etc.

    #!C:/usr/bin/perl.exeuse CGI':standard'; # 7a.plprint "content-type:text/html","\n\n";

    print "\n";print " About this server \n";print " About this server ","\n";print "";print "Server name :",$ENV{'SERVER_NAME'},"
    ";print "Running on port :",$ENV{'SERVER_PORT'},"
    ";print "Server Software :",$ENV{'SERVER_SOFTWARE'},"
    ";print "CGI-Revision :",$ENV{'GATEWAY_INTERFACE'},"
    ";print "\n";print "\n";exit(0);

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    29/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    30/53

    7b) Write a Perl program to accept UNIX command from a HTML

    form and to display the output of the command executed.(UNIX

    FLATFORM)

    #!/usr/bin/perluse CGI':standard'; # 7b.plprint "content type: text/html \n\n";$c=param('com');system($c);exit(0);

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    31/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    32/53

    8. a) Write a Perl program to accept the User Name and display a

    greeting message randomly chosen from a list of 4 greeting messages.

    #!C:/perl/bin/perl.exe #8a.pluse CGI ':standard';if(param)

    {print header();print start_html(-title=>"UnixCommand",-bgcolor=>"Green",-text=>"blue");$cmd=param("command");

    @l=("Hello","Hai","How r u","Thank u","Hello","Oh..","Is it...?","Where ru","When...?","What......?");

    $m=@l[rand()*10];print b("$m $cmd"),br();print start_form();

    print submit(-value=>"Back");print end_form();print end_html();}else{print header();print start_html(-title=>"Enter user name",-bgcolor=>"yellow",-text=>"blue");print start_form(),textfield(-name=>"command",-value=>" "),

    submit(-name=>"submit",-value=>"Submit"),reset();print end_form();

    print end_html();}

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    33/53

    OUPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    34/53

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    35/53

    8b) Write a Perl program to keep track of the number of visitors

    visiting the web page and to display this count of visitors, with proper

    headings.

    #!C:/perl/bin/perl.exe #8b.pluse CGI ':standard';

    print header();print start_html(-title=>"WebPage Counter",-bgcolor=>"Pink",text=>"blue");open(FILE,'count.txt');print FILE "$count";print b("This page has been viewed $count times");close(FILE);

    print end_html();

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    36/53

    OUPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    37/53

    9. Write a Perl program to display a digital clock which displays the

    current time of the server.

    #!C:/perl/bin/perl.exe #9.pluse CGI ':standard';print "Refresh: 1\n";

    print "Content-Type: text/html\n\n";

    print start_html(-title=>"Program 9",-bgcolor=>"Black",-text=>"white");

    ($s,$m,$h)=localtime(time);

    print br,br,"The current system time is $h:$m:$s";print br,br,hr,"In words $h hours $m minutes $s seconds";print end_html;

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    38/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    39/53

    10. Write a Perl program to insert name and age information entered

    by the user into a table created using MySQL and to display the

    current contents of this table.

    #!/usr/bin/perl # !10.plprint "content-type: text/html \n\n";

    print "Result of the insert operation ";use CGI':standard';use DBI;$dbh=DBI->connect("DBI:mysql:kishor","root");$name=param("name");$age=param("age");$qh=$dbh->prepare("insert into student values('$name','$age')");$qh->execute();$qh=$dbh->prepare("Select * from student");$qh->execute();print "NameAge";

    while ( ($name,$age)=$qh->fetchrow()){print "$name$age";}print "";$qh->finish();$dbh->disconnect();print"";

    Name :
    Age :

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    40/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    41/53

    11.Write a PHP program to store current date-time in a COOKIE and

    display the Last visited on date-time on the web page upon reopening

    of the same page.

  • 8/6/2019 Web Manual 27-11-09

    42/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    43/53

    12. Write a PHP program to store page views count in SESSION, to

    increment the count on each refresh, and to show the count on web

    page.

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    44/53

    OUTPUT:

    13a. Create a XHTML form with Name, Address Line 1, Address Line

    2, and E-mail text fields. On submitting, store the values in MySQL

    table. form information

    enter name: enter Address1:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    45/53

    enter Address2 enter email

  • 8/6/2019 Web Manual 27-11-09

    46/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    47/53

    13 b) Retrieve and display the data based on Name.

    search page

    enter the Name to be searched:

  • 8/6/2019 Web Manual 27-11-09

    48/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    49/53

    14 a)

  • 8/6/2019 Web Manual 27-11-09

    50/53

  • 8/6/2019 Web Manual 27-11-09

    51/53

    OUTPUT:

    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    52/53

    14 b)

    search pageenter the title of the book to be searched:



    Web Programming Lab Manual Dept. of CS&E

  • 8/6/2019 Web Manual 27-11-09

    53/53