Grade XII Unit 3. Web Technology II
UNIT 3. Web Technology II
Introduction to Web Technology
- The Web, or World Wide Web (WWW), is a network of interconnected web servers across the globe through the Internet.
- Web servers store billions of websites, each providing diverse information on various subjects through web pages.
- The Web is essentially a collection of HTML documents (web pages) linked together, spread across thousands of computers on the Internet.
- Web technology encompasses tools and technologies used for web development.
- It involves a variety of techniques facilitating communication between computers or devices over the internet.
- The methods within web technology include the use of markup languages and multimedia packages.
- The communication on the Internet occurs through interconnected computers or devices, creating a vast and dynamic network.
Client Side and Server Side Scripting
- A script language, also known as a scripting language, is an interpreted programming language crucial for adding dynamism and interactivity to web pages.
- Specifically designed for integration and communication with other programming languages.
- Users can create a series of instructions using a script language, executed in the run-time environment, enhancing the interactivity of web pages.
- There are two main types of scripting languages: client-side and server-side.
- Client-side scripting involves scripts executed on the user's browser, enhancing the user experience directly.
- Server-side scripting, on the other hand, involves scripts executed on the web server, influencing how web pages are generated and served to users.
Client side Scripting
- Client-side scripting involves writing programs that run on a client computer or device through a web browser.
- The codes in client-side scripting languages are executed by the user's web browser.
- It enables the addition of dynamic and interactive elements to web pages, enhancing their engagement and user-friendliness.
- Dynamic web pages permit users to change or customize content based on their input.
- Examples of client-side scripting languages include JavaScript, CSS, AJAX, jQuery, TypeScript, CoffeeScript, and VBScript.
- JavaScript is the most widely supported client-side scripting language, compatible with all major web browsers.
- VBScript, developed by Microsoft, has limited support among web browsers.
Features of Client Side Scripting
- The client side scripts are run on a web browser of a client computer or device.
- It is visible to the users.
- It loads a web page faster.
- It helps to reduce the load on the server by shifting some of the processing to the client-side.
- It doesn't interact with the server to process data.
Server side scripting
- Server-side scripting languages create dynamic web pages responding to user requests.
- Scripts run on the web server, generating HTML pages for the client's browser.
- Source code is hidden from the client, revealing only essential data for security.
- Popular server-side scripting languages include PHP, ASP.net, ColdFusion, Python, Ruby, Perl, C#, and JSP.
- Operations like website customization, dynamic content changes, query responses, database access, and user authentication occur on the server.
Features of Server Side Scripting
- It works with the back end.
- It runs on the web server.
- It provides a response to every request that comes in from the user/client.
- This is not visible to the client side of the application.
- It requires interaction with the server for the data to be processed.
- It is considered a secure way of working with applications.
- It can be used to customize web pages.
Introduction to JavaScript
Feature of JavaScript
- It is a light weighted and interpreted language which executes in a run-time environment directly through a web browser.
- It is supported by all the web browsers since 97% of all websites use JS.
- It is also a structural programming language since it supports control structures such as branching and looping.
- It is prototype based programming language which means we can create object without creating classes, so it is also a Object Oriented programming
- JavaScript is a case-sensitive language, small and upper case differs.
- Every operating system such as Windows, MacOS supports JS.
Uses of JavaScript
- JS is used for client-side validation.
- JS can be used to make dynamic drop-down menus.
- JS can be used to display date, time and even clock.
- JS can be used to generate pop-up windows, alert message, dialog box etc
- JS can also be used for Server applications.
- JS can be used for cross platform mobile apps development.
- can be used for game development.
Adding JavaScript to HTML document
JavaScript is often used as client-side scripting language along with HTML and CSS adding CSS to our HTML document, Similarly we can add JavaScript code to HTML document in three several ways. The several ways of adding JavaScript to HTML document are:
Inline JavaScript code
This method involves inserting JavaScript code directly within the HTML tags, eliminating the need for separate JS files or even the script tag. It's perfect for simple events like onclick, mouseover, or keypress. However, keep in mind that adding extensive JS code inline can be quite inconvenient. To add JavaScript code inline in an HTML document, follow the example below:
<HTML>
<HEAD>
<TITLE>Sample</TITLE>
</HEAD>
<BODY>
<BUTTON onclick = "alert('Your message')">Click me</BUTTON>
</BODY>
</HTML>
Here,
we have added
an alert message
through the onclick
event. When the user clicks
the Click me button then an alert message will be shown in the web browser.
Internal (Embedding) JavaScript code
Embedding JavaScript code internally within the HTML document is a convenient way to handle interactions. However, it's essential to be mindful of the script's placement and potential impacts on page loading. Here's a refined version:
External JavaScript code
<SCRIPT src = “name.js”></Script>
Create a HTML document with any name
Also create a JS file with .js extension and add following code
function disp(){
alert("Hello World!");
}
Variable:
Local Variable:
Global Variable:
Data type in JavaScript
Primitive data types: They are derived data types from primitive data types.
Types |
Function |
Number |
It represents numeric
value i.e. integer and floating number.
We can use BigInt to represent numbers with
large values. |
String |
It represent
alphanumeric values i.e. text |
Boolean |
It
represents either true or false value. |
Null |
It
represents an empty or unknown value. |
Undefined |
If a variable is declared but the
value is not assigned then the variable
is of undefined type. |
Non-Primitive data types: They are derived
data types from primitive data types.
Types |
Function |
Array |
It stores
multiple values of the same type under the same name. |
Object |
It has
methods and properties. |
Operators in JavaScript
Types of Operators in JS
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
% |
Remainder |
++ |
Increment |
- - |
Decrement |
== |
Equals |
!= |
Not equal to |
< |
Less than |
> |
Greater than |
>= |
Greater than
equal |
<= |
Less than
equal |
&& |
Logical AND |
|| |
Logical OR |
! |
Logical NOT |
= |
Simple equal
to |
+= |
Add and
assign |
-= |
Subtract and
assign |
*= |
Multiply and
assign |
/= |
Divide and
assign |
% |
Take remainder and assign |
Form Validation using JavaScript
CSS
- Web pages will load faster.
- It helps to maintain design consistency across all the pages of the Web site.
- CSS allows for customizing elements such as font, font size, font color and many other
- CSS can help to make Web pages available for different media (desktop PC, mobile phones). i.e. device responsive
- It makes web page compatible with almost all the browsers.
Server-side Scripting Using PHP
- Server-side scripting is a method of designing a website that processes or runs a user request on the web server.
- It is used to develop dynamic websites and web applications.
- It provides an interface to the user and hides the source code. It allows limited access to proprietary data.
- PHP, Python, Java, Ruby, Perl, ASP, C#, etc. are server-side scripting languages.
- PHP is the popular server-side scripting language that enables a user to develop interactive dynamic websites.
Introduction to PHP
- Hypertext Preprocessor (PHP) is an open-source programming language that is used to develop dynamic and interactive websites.
- It is the server-side scripting language that is embedded in HTML.
- It is used to manage dynamic content, databases, session tracking, etc.
- When a request is made by a user, a PHP interpreter on a web server executes PHP codes, and the plain HTML output is embedded in the HTML, which is sent to the viewer’s web browser.
- There is no special hardware requirement for PHP. It can be run in a computer having at least 200 MB of free hard disk space, 512 MB or higher RAM, and a core 2 duo or higher processor.
- It requires a web server (Apache server, IIS), PHP Interpreter (PHP Parser), and database software (MySQL).
- You can install a Web server, PHP interpreter (i.e. PHP Parser), and MySQL database separately on a computer.
- Some packages like WAMP(compatible with Windows 2008 or higher), LAMP (compatible with Linux), XAMPP (compatible with Windows/Linux/MAC), and MAMP (compatible with MAC) allow you to install a web server, PHP interpreter, and MySQL Database all together on a computer.
Making a computer ready to use PHP
- Download the installation file of XAMPP from https://www.apachefriends.org site and install it on a computer.
- Open XAMPP Control Panel that allows you to configure the XAMPP and enables you to start or stop the modules.
- Start Apache server and MySQL.
- Type PHP codes in a text editor like Notepad, Notepad++, NetBean, CoffeeCup, EditPlus, Sublime Text and save the php file in C:\XAMPP\htdocs folder. Suppose the name of php file is 'myfirstphp.php'.
- Open a web browser and type http://localhost/php filename. For example, http://localhost/myfirstphp.php.
- Object-Oriented Programming (OOP) is a programming approach or paradigm that is based on classes and objects.
- In OPP, a class is a programmer-defined data type that includes local methods (i.e., local function) and local variables.
- A class is a collection of objects and is identified by its ID i.e. class ID. A class id defined by using the class keyword followed by the name of the class and a pair of curly braces.
- All the methods and properties are included inside the curly braces.
- An object is an individual instance of the data structure defined by a class.
- Multiple objects can be created under a class.
- Each object has all the properties with different values and methods defined in the class.
- A new object of a class can be created by using new keyword.
- A PHP script can be placed anywhere in the PHP document.
- A PHP interpreter recognizes the PHP script placed anywhere in the document by the syntax.
- Each PHP script starts with <?php and ends with ?>.
- Syntax:
// PHP code
?>
- A PHP file is saved with a .php extension.
- A PHP file normally contains HTML tags and PHP scripting codes.
- Each PHP code is terminated with a semicolon.
- The echo and print statements are used for displaying output.
- In PHP, keywords (if, else, while, echo, etc.), classes, functions, and user-defined functions are not case-sensitive.
- A single-line comment can be put by using either // or #.
- A multi-line comment can be put by using /* followed by comment or remark and terminated by */.
- PHP data type refers to the type of data that can be used in PHP. Since PHP is a loosely typed language, variables do not need to be declared with a specific data type.
- PHP supports String, Integer, Float, Boolean, Null, Array, Object, and Resource data types.
- The string data type refers to a sequence of characters enclosed in single or double quotes. "Namaste" and ‘Symbol no:877897’ are examples of string data.
- The Integer data type is a whole number ranging from -2147483648 to 2147483647 i.e. -2^31 to 2^31. It can be specified in the decimal, octal, binary, or hexadecimal number system. The decimal number system is the default number system for specifying PHP integers. 45, 4265, ox1A, etc. are integers. The PHP var_dump() function returns the data type and value.
- The Float (also known as double) data type refers to a number with a decimal point. It can be expressed in exponential form. 125.55, 7.65E+4, 5.45-3, etc. are floats.
- The Boolean data type is the logical data type that refers to a value of either true or false. In PHP, the value of true is represented by 1, and the value of false is represented by 0. PHP uses the bool keyword to represent the Boolean data type. It is not case-sensitive. PHP treats empty string (" ", ‘ ’), string "0", empty array (array() or []), null, float 0.0, float -0.0, integer 0, integer -0, and false keyword as false.
- An array is a compound data type that allows a user to store multiple data of the same data type in a single variable. Each value in an array is represented by an index. For example, $color=array(‘red', ‘blue', ‘green'); defines three string values. $color[0], and $carts[1] represent the 1st and 2nd elements of the $color array.
- An object data type is a user-defined data type that stores data and behavior. An object is created from a class, which defines the properties and methods of the object. Let's assume we have a class named Car. A Car can have properties like model, color, etc. We can define variables like $model, $color, and so on, to hold the values of these properties. When the individual objects (Volvo, BMW, Toyota, etc.) are created, they inherit all the properties and behaviors from the class, but each object will have different values for the properties.
- The null data type refers to a null value i.e. no value. When a variable is created without a value in PHP, it is automatically assigned a value of null. A variable of data type NULL is a variable without any data. NULL is the only possible value of the null data type.
- A resource data type stores the reference to functions and an external resource. Resource variables typically hold special handlers for opened files and database connections.
- A variable starts with the $ sign, followed by the name of the variable.
- A variable name can only contain alpha-numeric characters and underscores (A-Z, a-z, 0-9, and _ ).
- A variable name must start with a letter or the underscore character.
- A variable name cannot start with a number.
- Variable names are case-sensitive ($age and $AGE are two different variables).
- Oracle, MS-Access, Sybase, Microsoft SQL Server, and MySQL are some popular database software.
- PHP supports various kinds of database connections with it.
- MySQL is the relational database management system (RDBMS) developed, distributed, and supported by Oracle Corporation and it is commonly used on the Web nowadays.
- MYSQL supports standard SQL (Structured Query Language) and stores data in tables that consist of columns and rows.
- Each row of a table stores interrelated data of someone or something and is known as a record.
- Each column of a table stores a piece of information related to someone or something. A column of a table is known as a field.
- The structure of a table in MySQL looks like below:
- Run the MySQL database server to establish the connection with the MySQL database.
- Type http://hocalhost/phpmyadmin/ in a browser to check whether it is running or not.
Comments
Post a Comment