15 Tybca WT Lab File
15 Tybca WT Lab File
INDEX
Sr.No Title Page no
UNIT 1
1. Introduction to Web Technology
1.1. Introduction to different type of web browsers:
1. WorldWideWeb
2. Mosaic
3. Netscape Navigator
4. Internet Explorer
5. Firefox
6. Google Chrome
b. IP:
IP stands for “Internet Protocol”, which is the set of rules
governing the format of data sent via the internet or local
network. The internet needs a way to differentiate between
different computers, routers, and websites. IP addresses provides
a way of doing so and form an essential part f how the internet
works.
c. UDP:
User Datagram Protocol is a communications protocol that
facilitates the exchange of messages between computing devices
in a network. It's an alternative to the transmission control
protocol.
d. HTTP:
Hypertext Transfer Protocol is an application-layer protocol for
transmitting hypermedia documents, such as HTML. It was
designed for communication between web browsers and web
servers, but it can also be used for other purpose.
e. HTTPS:
Hypertext Transfer Protocol Secure is a combination of the
hypertext transfer protocol with the secure socket layer
(SSL)/Transport Layer Security (TLS) protocol. TLC is an
authentication and security protocol widely implemented in
browsers and web servers.
10
f. FTP:
File Transfer Protocol refers to a group of rules that govern how
computers transfer files from one system to another over the
internet. Businesses use FTP to send files between computers,
while websites use FTP for the uploading and downloading files
form their website’s servers.
g. TFTP:
Trivial File Transfer Protocol is a simple protocol that provides
basic file transfer function with no user authentication. TFTP is
intended for applications that do not need the sophisticated
interactions that File Transfer protocol provides.
h. SMTP:
Simple Mail Transfer Protocol is a set of communication
guidelines that allow software to transmit an electronic mail over
the internet. It is a program used fr sending messages to other
computer users based on e-mail addresses.
i. MIME:
MIME (Multipurpose Internet Mail Extensions) is a standard
which was proposed by Bell Communications in 1991 in order to
expand upon the limited capabilities of email, and in particular to
allow documents (such as images, sound, and text) to be inserted
in a message.
11
UNIT 2
2. Basic operators:
3. Decision statements:
3.1. If statement
Code:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript if</h2>
<p>Display "GOOD MORNING" if the hour is less than
18:00:</p>
<p id="demo">GOOD AFTERNOON!!</p>
<script>
if (new Date().getHours() < 18) {
document.getElementById("demo").innerHTML = "Good
day!";
}
</script>
</body>
</html>
Output:
JavaScript if
Display”GOOD MORNING” if the hour is less than 12:00:
GOOD AFTERNOON!!
14
Code:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript if .. else</h2>
<p>A time-based greeting:</p>
<p id="demo"></p>
<script>
const hour = new Date().getHours();
let greeting;
if (hour < 18) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
document.getElementById("demo").innerHTML = greeting;
</script>
</body>
</html>
Output:
15
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
document.getElementById("demo").innerHTML = "Today is
" + day;
</script>
</body>
</html>
Output:
4. Looping statements:
4.1. For loop:
Code:
<!DOCTYPE html>
<html>
<body>
17
Output:
JavaScript For Loop
wagonR
Ertiga
Kiger
Triber
Code:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript While Loop</h2>
<p id="demo"></p>
<script>
18
Output:
Code:
<!DOCTYPE html>
<html>
19
<body>
<h2>JavaScript Do While Loop</h2>
<p id="demo"></p>
<script>
let text = ""
let i = 0;
do {
text += "<br>The number is " + i;
i++;
}
while (i < 10);
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
Output:
5. Functions:
20
Code:
<html>
<head>
<title>Functions</title>
<script language="javascript" type="text/javascript">
function alert_box(msg)
21
{
document.bgColor="#EEEEEE";
alert(msg);
}
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
alert_box("Welcome to Goa");
</script>
</body>
</html>
Output:
Code:
<!DOCTYPE html>
<html>
<head>
<title> Introduction to Objects </title>
<script type="text/javascript">
//DOM Manipulation and
getElementByIdMethod//
function buttonClick()
{
var n
=document.getElementById("heading2").innerHTML;
alert(n);
24
</script>
</head>
<body>
<button onclick="buttonClick()">Click
Me</button>
<h2 id="heading2">Some Random Text</h2>
</body>
</html>
Output:
Code:
<html>
<head>
<title>DOMS using JS</title>
<script type="text/javascript">
25
function styleChange()
{
var para=document.getElementsByClassName("pt");
for(var i=0; i<para.length;i++)
{
para[i].style.fontSize=24;
para[i].style.fontWeight="bold";
para[i].style.fontStyle="italic";
}
}
</script>
</head>
<body bgcolor = "black">
<p class="a" style="color:tomato">#1 Paragraph</p>
<p class="pt" style="color:tomato">#2 Paragraph</p>
<p class="a" style="color:tomato">#3 Paragraph</p>
<p class="pt" style="color:tomato">#4 Paragraph</p>
<p class="pt" style="color:tomato">#5 Paragraph</p>
<button onclick="styleChange()"name="submit">change
Style </button>
</body>
</html>
Output:
26
2. Form Validation:
Required Filed validation:
Code:
<!DOCTYPE html>
<html>
<head>
<script>
function validateForm()
{
28
var x=document.myForm.fname.value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="demo_form.php"
onsubmit="return validateForm()” method="post">
First name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
</body>
</html>
Output:
With error
Without error
29
Email validation:
Code:
<html>
<head><script>
function validateForm()
{
var x=document.myForm.email.value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
}
</script></head>
<body>
<form name="myForm" action="demo_form.php"
onsubmit="return validateForm();"
method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">
30
</form>
</body>
</html>
Output:
With error
Without error:
if (document.myForm.Zip.value == ""
||isNaN(document.myForm.Zip.value)
||document.myForm.Zip.value.length !=5)
{
alert("please provide a zip in the format
######.");
document.myForm.Zip.focus();
return false;
}
}
</script>
</head>
<body>
<h1>ZIP code validation</h1>
<form name="myForm"
onsubmit="return(validate());">
<label>Zip Code:</label><input type="number"
name="Zip" /><br /><br>
<input type="submit" value="Submit" class="sub">
</div>
</form>
</body>
</html>
Output:
32
3. Mouse events
<html>
<head>
<title>DOMS using js</title>
<script type="text/javascript">
function setNewImage()
{
document.getElementById("x").src="WIN_20210717_09_58_19_Pro.jpg
"
}
function setOldImage()
{
document.getElementById("x").src="Screenshot (708).png"
}
</script>
</head>
<body bgcolor="green">
<img id="x" src="" height="300" width="300"
onmouseover="setNewImage()"
onmouseout="setOldImage()"></img>
</body>
</html>
33
Output
AJAX
Code
Retrieving of Data
Part 1
<script src="https://code.jquery.com/jquery-2.2.4.min.js">
</script>
<a href="javascript:void(0)" onclick="click_here()">click me</a>
<script>
function click_here()
{
jQuery.ajax({
url:'ajax2.php',
type:'post',
success:function(result){
alert(result);
}
});
}
</script>
34
Code
Part 2
<?php
echo "THIS IS THE AJAX PAGE FROM WHERE DATA IS RETRIEVED";
?>
Output
Code
Adding
Part 1
<script src="https://code.jquery.com/jquery-2.2.4.min.js">
</script>
<input type="textbox" id="num1"/>
<a href="javascript:void(0)" onclick="click_aj()">click me</a>
<script>
function click_aj()
{
var num1=jQuery('#num1').val();
jQuery.ajax({
url:'ajax4.php',
type:'post',
data:'num1='+num1,
35
success:function(result){
alert(result);
}
});
}
</script>
Part 2
<?php
echo $_POST['num1']+50;
?>
Output
Code
Result 1 and Result 2
Part 1
<script src="https://code.jquery.com/jquery-2.2.4.min.js">
</script>
<script>
Result1();
Result2();
function Result1()
{
36
jQuery.ajax({
url:'ajax6.php',
type:'post',
async:false,
success:function(result){
alert(result);
//console.log(result);
}
});
}
function Result2()
{
jQuery.ajax({
url:'ajax7.php',
type:'post',
//async:false,
success:function(result){
alert(result);
//console.log(result);
}
});
}
</script>
37
Part 2
<?php
sleep(5);
echo "THIS IS RESULT 1";
?>
Part 3
<?php
echo "THIS IS RESULT 2";
?>
Output
38
UNIT 3
1. What is XML?
Xml (eXtensible Markup Language) is a markup language. XML is
designed to store and transport data. Xml was released in late 90’s.
it was created to provide an easy to use and store self-describing
data. XML became a W3C Recommendation on February 10, 1998.
3. Schema:
b. XML Schema is an XML-based (and more powerful)
alternative to DTD. It Do not use EBNF grammar
c. The XML Schema language is also referred to as XML
Schema Definition (XSD).
d. One of the greatest strengths of XML Schemas is the
support for data types.
e. XML Schemas is that are written in XML so you don't have
to learn a new language.
4. XML Namespaces
In XML, element names are defined by the developer. This often
results in a conflict when trying to mix XML documents from
different XML applications. E.g., Tel, phone, mobile
This Naming collisions Name can easily be avoided using a name
prefix.
When using prefixes in XML, a so-called namespace for the prefix
must be defined.
The namespace is defined by the xmlns attribute in the start tag
of an element.
41
<tiger>Bengal tiger</tiger>
<tiger>glucose tiger</tiger>
Namespaces
<animal:tiger>Bengal tiger</animal:tiger>
<biscuit:tiger>glucose tiger</biscuit:tiger>
Creating namespaces
Xmlns:animal=”urn:sxc:animalInfo”
Xmlns:biscuit=”urn:sxc:foodInfo”
5.3. XPath
UNIT 4
Grid container
<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
display: grid;
grid-template-columns: auto auto auto auto;
gap: 10px;
background-color: #2196F3;
padding: 10px;
}
<h1>Grid Container</h1>
44
<div class="grid-container">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
</div>
</body>
</html>
Output
45
Justify-content
<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
display: grid;
justify-content: space-evenly;
grid-template-columns: 50px 50px 50px; /*Make the grid smaller than
the container*/
gap: 10px;
background-color: #2196F3;
padding: 10px;
}
<div class="grid-container">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</body>
</html>
Output
47
<h1>Grid Elements</h1>
<div class="grid-container">
<div class="grid-item"><img src="Screenshot (730).png"
width="100px" height = "90px"></div>
<div class="grid-item"><img src="Screenshot (730).png"
width="100px" height = "90px"></div>
<div class="grid-item"><img src="Screenshot (730).png"
width="100px" height = "90px"></div>
<div class="grid-item"><img src="Screenshot (730).png"
width="100px" height = "90px"></div>
<div class="grid-item"><img src="Screenshot (730).png"
width="100px" height = "90px"></div>
<div class="grid-item"><img src="Screenshot (730).png"
width="100px" height = "90px"></div>
<div class="grid-item"><img src="Screenshot (730).png"
width="100px" height = "90px"></div>
<div class="grid-item"><img src="Screenshot (730).png"
width="100px" height = "90px"></div>
<div class="grid-item"><img src="Screenshot (730).png"
width="100px" height = "90px"></div>
</div>
</body>
</html>
49
Output
50
UNIT 5
ActiveVFP
ASP
C
DC
Java
JavaScript (using SSJS (Server-side JavaScript) e.g., node.js)
Perl
PHP
Python
R
Ruby
2. Introduction to PHP
What is PHP?
PHP files can contain text, HTML, CSS, JavaScript, and PHP code
PHP code is executed on the server, and the result is returned to
the browser as plain HTML
PHP files have extension ".php"
With PHP you are not limited to output HTML. You can output images,
PDF files, and even Flash movies. You can also output any text, such as
XHTML and XML.
Why PHP?
Output statement:
The PHP echo statement is often used to output data to the screen.
Code snippet:
<?php
echo "hello world!";
?>
Output:
Input statement
The <input> tag from HTML is a method used to get input from the used
Code:
<!DOCTYPE html>
<html>
<body>
<form action ="input.php" method="get">
number1:<br>
<input name="num1"><br><br>
<input type="submit" value="submit">
</body>
</html>
Input.php
<?php
$a=$_GET['num1'];
echo"entered number is $a";
?>
Output:
54
if else statement
elseif statement
switch statement
If else Statement:
Code snippet:
<?php
$date=date("01-10");
if ($date=="01-10") {
else{
55
?>
Output:
4. Else if Statement:
Code snippet:
<?php
$date=date("m-d");
if ($date=="01-10") {
echo "Wishing you a very Happy Birthday";
}
elseif($date=="08-15"){
echo "Happy Independence Day";
}
else{
56
Output:
Switch Statement:
Use the switch statement to select one of many blocks of code to be
executed
Code snippet:
<?php
$myFavColor='red';
switch ($myFavColor)
{
case 'pink':
echo 'My favorite car color is pink!';
break;
case 'red':
echo 'My favorite car color is red!';
break;
57
case 'orange':
echo 'My favorite car color is orange!';
break;
default:
echo 'My favorite car color is not pink, red, or orange!';
}
?>
Output:
58
Looping Statements:
while loop
do-while loop
for loop
foreach loop
While Loop:
PHP while loop statement allows to repeatedly run the same block of
code until a condition is met.
Code snippet:
<?php
$i = 1;
$i++;
?>
Output:
Do While Loop
PHP do while loop is very similar to the while loop, but it always
executes the code block at least once and furthermore as long as the
condition remains true.
Code snippet:
<?php
$i=0;
do{
$i++;
echo "php do...while loop $i times"."<br>";
}
while ($i<=5);
?>
60
Output:
For Loop:
PHP for loop is very similar to a while loop in that it continues to process
a block of code until a statement becomes false, and everything is
defined in a single line.
Code snippet:
<?php
for ($i=1; $i <= 5; $i++ ){
echo "PHP for loop print $i times"."<br>";
}
?>
Output:
61
The foreach loop is mainly used for looping through the values of an
array. It loops over the array, and each value for the current array
element is assigned to $value, and the array pointer is advanced by one
to go the next element in the array.
Code snippet:
<?php
$salary[0]=2000;
$salary[1]=3000;
$salary[2]=5000;
foreach($salary as $value){
echo "Salary: $value<br>";
}
?>
Output:
62
PHP Functions
Code:
<?php
Function add($a,$b){
$total = $a + $b;
return $total; //Function return, No output is shown
}
Code:
<?php
function addFunction($number, $number)
{
$number = $number + $number;
echo "The sum of two numbers is : $number"; //Outputs as 30
}
addFunction(10, 20);
?>
Code:
<?php
function setWeight($minWeight=50){
echo "The weight is: $minWeight <br>";
}
setWeight(100);
64
setWeight(125);
setWeight(75);
setWeight(); // will use the default value of 50
?>
Returning Values
All functions in PHP return a value, even if you don't explicitly cause
them to. Thus, the concept of "void" functions does not apply to PHP.
You can specify the return value of your function by using the return
keyword:
Code:
<?php
function hello(){
return "Hello World"; // No output is shown
}
$txt = hello(); // Assigns the return value "Hello World" to $txt
echo hello(); // Direct Displays "Hello World"
?>
65
Database Connectivity:
Crud Operations:
Within computer programming, the acronym CRUD stands for create,
read, update and delete. These are the four basic functions of persistent
storage. Also, each letter in the acronym can refer to all functions
executed in relational database applications and mapped to a standard
HTTP method, SQL statement or DDS operation.
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create database
$sql = "CREATE DATABASE myDB";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}
$conn->close();
?>
66
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$conn->close();
?>
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
67
$conn->close();
?>
PHP cookies:
Create a Cookie
Setcookie() function is used to set a cookie.
Syntax:
setcookie(name, value, expiration);
$name - a name of the
cookie. Example: "username"
$value - a value of the
cookie. Example: "Jhon"
$expire - time (in UNIX
timestamp) when the cookie will expire. Example: time()+"3600".
A cookie is set to expire after one hour.
Example:
<?php setcookie("username", "Jhon", time()+3600); ?>
68
Cookie username is set with value Vijay which is set to expire after one
hour on the user's computer.
Example:
<?php echo $_COOKIE["username"]; ?>
Delete a Cookie
To delete cookies, you just need to set a cookie on past date.
The following PHP code will delete, username cookie.
Example:
<?php setcookie("username", "Jhon", time()-3600); ?>
PHP Sessions:
PHP session is used to store information on the server. The data will be
available to all pages in one application.
<html>
70
<body>
</body>
</html>
When you start a session a unique session id (PHPSESSID) for each
visitor/user is created. You can access the session id using the
PHP session_id() function or predefined constant PHPSESSID.
Destroying a Session
A complete PHP session can be terminated by
using session_destroy() function, which does not require any arguments.
Example:
<?php
session_start();
session_destroy();
?>
If you wish to delete a single session variable, then you can
use unset() function.
Example:
<?php
session_start();
if(isset($_SESSION[username]))
unset($_SESSION[username]);
?>
72
UNIT 6
1. WEB FRAMEWORK
Laravel is one of the world’s most popular PHP frameworks for building web
applications from small to large projects. for the development of web
applications following the model–view–controller (MVC) architectural
pattern. Some of the features of Laravel are a modular packaging
system with a dedicated dependency manager, different ways for
accessing relational databases.
Laravel modules
Laravel API
Laravel API helps to transfer data from one technology to another Laravel
API helps to transfer data from backend to frontend or frontend to backend
Blade Template
Security in Laravel
as define the controllers – the rest is for the system to take care of. The
built-in authentication features will automatically start to get synched with
the site or the app.
SET 1
Installing Laravel
2. Install Composer
5. To open the project, type out the below command on command prompt.
6. To open Laravel project on this port go to browser and type out the port
number: 127.0.0.1;8000
7. We can’t directly run Laravel so we have to open xampp and run apache
9. Go to your browser and type -> localhost and paste that path you copied.
12. Now to create your own port and assign the project there
-Remove the comments and remove the codes and keep the virtual host
-now to open that path with the help of any name we have to do the below
steps:-
i) Copy the htdocs path name, give any name to the server name that you’ll
use on the browser address bar.
76
UNIT 7
1. Types of web hosting
Free Hosting:
Some ISPs offer free web hosting. Free web hosting is best suited for
small sites with low traffic, like personal sites. It is not recommended
for high traffic or for real business. Technical support is often limited,
and technical options are few. Very often you cannot use your own
domain name at a free site. You have to use a name provided by
your host like http://www.freesite.com/users/~yoursite.htm. This is
hard to type, hard to remember, and not very professional.
Website Builders:
Dedicated:
Shared Hosting:
Grid Hosting:
Co-located Hosting:
Step 1: go to a site where you can buy domain name for example
godaddy.com and searcher if the domain name you want is available.
79
Step 2: after you search for the domain main it will show you all the
available option to choose from.
Step 3: from the available option select the domain name you want and
click buy now.
80
Step 4: you will see your desired domain name added to the cart.
Step 5: it will show you your total amount of how much you will have to
pay to buy the domain name.
You can use your domain cPanel Zone editor to configure a wide range
of records that the nameserver relies on. This allows you to add and edit
records such as the servers, IP addresses, and more.
After changing the nameservers, either from the registrar, or from one
host to another, the DNS records are usually overwritten by those of the
hosting provider.
However, you can use the domain Zone editor to create or edit some
entries such as those for the mail servers, subdomains, FTP, etc.
If you have several domains, select the domain you want to configure
and click the record you want to add.
The zone editor above only allows you to add A, CNAME or MX records.
However, clicking Manage gives the option to add more record entries.
If you click add A Record, you will be prompted to enter the subdomain
name and an IP address since the domain is already there.
Select the domain you want to configure and click Manage, (it gives you
an option to add other records or edit existing ones).
To add a record, click + Add Record.
Select the record you want to add and proceed.
Editing a record
Click Edit for the field you want to change and insert your settings. For
example, to edit the MX records for the mail server;
Click Add MX Record
Type your mail server name such as mail.yourdomainname.com
Type the IP address for your mail server
Save Record
Most domain registrars, who also provide hosting, will by default use
their nameserver for all the domains they have registered. However, the
domain owner can point it to another hosting server away from the
registrar.
dns1.registrar-name.com
, or
dns1.host-name.com
dns2.registrar-name.com
86
, or
dns2.host-name.com
ns1.registrar-name.com
, or
ns1.host-name.com
ns2.registrar-name.com
or
ns2.host-name.com
By default, the registrar will point the domain to their nameservers. If
you host your domain away from the registrar or moves to a different
host, you need to change the nameservers at your domain registrar’s
dashboard.
Once you change the nameservers for your domain, the new settings do
not become active immediately. It takes several hours for the new
settings to propagate throughout the internet. During part of this
propagation period, the domain and hence your website will be down
and inaccessible. As such, the best time to change is during the weekend,
night or any other low traffic period.
87
4. Web Security
Authentication
Authorization
Confidentiality
Data / Message integrity
Availability
Accountability
Non-repudiation
4.2. Cryptography
Cryptography is the practice and study of techniques for secure
communication in the presence of third parties (called adversaries)
More generally, it is about constructing and analyzing protocols that
overcome the influence of adversaries and which are related to various
aspects in information security such as data confidentiality, data
integrity, authentication, and non-repudiation
Cryptography intersects the disciplines of mathematics, computer
science, and electrical engineering.
Applications of cryptography include ATM cards, computer passwords,
and electronic commerce.
The modern field of cryptography can be divided into several areas of
study. The chief ones are discussed here:
Public Key Encryption or Asymmetric key-based algorithm,
Symmetric key-based algorithms, or block-and-stream ciphers,
Hashing, or creating a digital summary of a string or file
Digital signature