Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Institute of Engineering & Technology,

Sitapur

BACHELOR OF TECHNOLOGY
LECTURE NOTES

ON
Web Technology

SUBJECT CODE :- (KCS-602)

BY

Asst. Prof. Durgesh Kumar Gupta


Unit 1

Introduction and Web Development Strategies

The World Wide Web is a network of interconnected hypertext documents that can be accessed through the
Internet. The World Wide Web is a massive array of interconnected pages of information from all over the
world.
World Wide Web, which is also known as a Web, is a collection of websites or web pages stored in web
servers and connected to local computers through the internet. These websites contain text pages, digital
images, audios, videos, etc. Users can access the content of these sites from any part of the world over the
internet using their devices such as computers, laptops, cell phones, etc. The WWW, along with the internet,
enables the retrieval and display of text and media to your device.
The building blocks of the Web are web pages which are formatted in HTML and connected by links called
"hypertext" or hyperlinks and accessed by HTTP. These links are electronic connections that link related
pieces of information so that users can access the desired information quickly. Hypertext offers the advantage
to select a word or phrase from text and thus to access other pages that provide additional information related
to that word or phrase.
A web page is given an online address called a Uniform Resource Locator (URL). A particular collection of
web pages that belong to a specific URL is called a website, e.g., www.facebook.com, www.google.com, etc.
So, the World Wide Web is like a huge electronic book whose pages are stored on multiple servers across the
world.

Key takes away:


 The World Wide Web is a network of interconnected hypertext documents that can be accessed
through the Internet.
 The World Wide Web is a massive array of interconnected pages of information from all over the
world.

History of Web and Internet

 Sir Tim Berners-Lee founded the World Wide Web in 1989 at CERN in Geneva.
 The first text-only browsers were installed in 1990, allowing CERN scientists to access hypertext files
and other information. HTML was built on a subset of the generalized markup language norm
(SGML). A new protocol called HTTP was created to move HTML documents to remote sites
(Hypertext Transfer Protocol).
 In the fall of 1991, conference goers all over the world began to learn about the pledge, but no sparks
flew.
 There were only around 50 websites on the internet in 1993. The National Center for Supercomputing
application created a browser that enabled users to take advantage of the web's graphical capabilities
(NCSA). The browser was given the name Mosaic by NCSA.
Internet
When man first walked on the moon in 1969, the US defense department established the Advanced Research
Project Agency (ARPA) to conduct further research. To exchange and share their data, they created a network
of four computers.
ARPANET (Advanced Research Project Agency Network) was the name of this network. Many universities
were later permitted to enter this network and exchange data. This was the start of 'computer networking,'
which grew in size day by day and eventually gave birth to INTERNET, the technology that has changed our
lives.
Engineers, scientists, and computer experts used the Internet for research purposes in the past. The network
was gradually opened up to private agencies and the general public. People began to use it to transfer
messages and files back and forth between computers.
The most fascinating aspect of the Internet is that it is not regulated or maintained by a single entity. The
ARPANET expanded around the globe in 1972, with 23 nodes in various countries, and thus became known
as the Internet.
Many universities were later permitted to enter this network and exchange data. The Internet is unique in that
it is not regulated or maintained by a single entity. It cannot be monopolized or hijacked.

Key takes away:


 Sir Tim Berners-Lee founded the World Wide Web in 1989 at CERN in Geneva.
 Engineers, scientists, and computer experts used the Internet for research purposes in the past.

Protocols Governing Web

A protocol is a collection of rules that programs use to communicate with one another.
OR
A protocol is the interface that allows various programs to communicate with one another.

Classifications
HTML
TCP/IP
FTP
E-MAIL
TELNET

HTML: The most popular protocol for distributing information on the internet is HTTP.
The initial version of HTTP 0.9 does not allow for content typing and does not provide provisions for
providing meta-data.
Content typing - To figure out what kind of data is being sent.
Meta information -The client's compute is identified by supplementary data, such as environment variables.
TCP/IP: It is a collection of rules that an application may use to bundle its data for transmission through a
network of networks.
FTP: It's used to send files through networks.
E-MAIL: It's a way of sending and receiving digital messages over the Internet or other computer networks.
Telnet: Telnet allows you to remotely log into another device and access the files and folders.

Key takes away:


• A protocol is a collection of rules that programs use to communicate with one another.

Writing Web Projects

A. Write a project mission statement: Make a mission statement that is unique to what you intend to
accomplish.

B. Identify Objectives
Objectives:

1. Specific
II. Measurable
III. Attainable
IV. Realistic
V. Time limited
C. Identify your target user: The users that you choose to visit the site will decide the subject of the website.
This is entirely dependent on.
1. Market research
11. Focus group
III. Understanding intranet audiences
D. Determine the scope: With the help of supporting documentation and the client's approval.
E. Budget:
i. Assumption for budgets.
ii. Budget categories.
iii. Determine hidden costs and tools
F. Planning Issues:
i. Discuss the client's existing information system.
ii. Project team and developing infrastructure
iii. Where the website will place.

Connecting to Internet

There are various ways to link laptops, desktop computers, cell phones, and tablets to the Internet in today's
world. It's critical to consider the differences between each link when deciding which form of Internet
connection is best for us.
A personal electronic device may attach to the internet in a variety of ways. They're all different in terms of
hardware and link speeds. To keep up with technological advancements, faster internet connections are
needed. I figured it would be fun to put together a list of the various types of internet connections available for
home and personal use, along with their average speeds.

The following are some of the most commonly used Internet connections.
 Dial-up connection: Dial-up Internet access is inexpensive, but it is slow. After the device dials a
phone number, an internal or external modem connects to the Internet. This analog signal is converted
to digital by the modem and transmitted over a public telephone network-connected landline. The
efficiency of telephone lines varies, and the communication can be spotty at times. Interference occurs
frequently on the tracks, affecting the pace, which ranges from 28 to 56 kilometers per hour. A
machine or other system that uses the same line as the telephone cannot be used simultaneously.
 Cable connection: Cable runs over cable TV lines and offers an internet connection through a cable
modem. There are different speeds depending on whether you are uploading or downloading data. You
will get quicker connectivity because coax cable has far more bandwidth than dial-up or DSL
telephone lines. Speeds on cable range from 512K to 20 Mbps.
 Leased connection: A leased link is a permanent telephone connection set up by a telecommunication's
common carrier between two locations. Leased lines are typically used by companies to link offices
that are geographically separated.
A leased line, unlike a regular dial-up link, is still active. The link fee is set at a monthly rate. The gap
between end points and the circuit's speed are the two most important factors that influence the monthly
charge. The carrier can guarantee a certain degree of service since the link does not hold someone else's
communications.

 DSL connection: Digital Subscriber Line (DSL) is the abbreviation for Digital Subscriber Line. It is a
link to the internet that is still "on." Since two lines are used, your phone will not be tethered while
your device is attached. To bind, you don't even need to dial a phone number. DSL uses a router to
transport data, with link speeds ranging from 128K to 8 Mbps depending on the service.

Key takeaway:
 There are various ways to link laptops, desktop computers, cell phones, and tablets to the Internet in
today's world.
 A personal electronic device may attach to the internet in a variety of ways. They're all different in
terms of hardware and link speeds.
 Cable runs over cable TV lines and offers an internet connection through a cable modem.
 A leased link is a permanent telephone connection set up by a telecommunication's common carrier
between two locations.

Introduction to Internet services and tools

We can use internet services to access a vast amount of information such as text, graphics, sound, and apps.
The diagram below depicts the four different types of Internet Services.
Communication services

There are a variety of communication services available that enable individuals or groups to share
information.

Below provides a quick overview of these facilities.


 Electronic mail - It's a kind of electronic message that's sent over the internet.
 Telnet - It's used to connect to a remote device that's connected to the internet.
 Newsgroup - Provides a platform for people to talk about shared interests.
 Internet Relay Chat (IRC) - Allows people to connect in real time from all over the world.
 Mailing Lists-Used to bring together a community of internet users to exchange information via
email.
 Internet Telephony - Allows internet users to speak to any PC configured to take calls over the
internet.
 Instant Messaging - Real-time chat between individuals and groups of people is accessible. For
example, Yahoo Messenger and MSN Messenger.

Information Services

There are a number of information retrieval services that provide quick access to information on the internet.

Below provides a quick overview of these facilities.


 File Transfer Protocol (FTP) - Allow users to send and receive files.
 Archie - It is a continuously maintained directory of public FTP sites and their contents. It makes it
easier to find a file by its name.
 Gopher - On remote locations, it's used to scan for, retrieve, and view documents.
 Very Easy Rodent Oriented Netwide Index to Computer Achieved (VERONICA) - The VERONICA
resource is a gopher-based resource. It gives users access to information stored on Gopher's servers.

Web services
 Web services enable information to be exchanged between web-based applications.
 Web services enable applications to easily communicate with one another.

The web services are offered using the concept of Utility Computing.

World Wide Web

W3 is another name for WWW. It allows users to view documents stored on several servers across the
internet. Text, graphics, audio, video, and hyperlinks can all be found in these documents. Users can navigate
between documents using the hyperlinks.
Key takes away:

 We can use internet services to access a vast amount of information such as text, graphics, sound, and
apps
 Web services enable information to be exchanged between web-based applications.
 W3 is another name for WWW. It allows users to view documents stored on several servers across the
internet

Introduction to client-server computing

In client-server computing, a client requests a resource, which the server fulfills. Although a client is only in
touch with one server, a server may support several clients at the same time. Both the client and the server
typically communicate over a computer network, but they may also share a single device.
The client-server system is depicted in the diagram below.

Characteristics of client-server computing

The following are the most important aspects of client-server computing:

 A request and response framework is used in client-server computing. The client makes a request to
the server, which the server fulfills by providing the requested information.
 The client and server can use the same communication protocol to make it easier for them to
communicate with one another. At the application layer, all communication protocols are open.
 A server can only handle a certain number of client requests at any given time. As a result, it
responds to requests using a priority-based system.
 By flooding a server with false requests, denial of service attacks make it difficult for it to respond to
legitimate client requests.
 A web server is an example of a client-server operating system. It sends requested web pages back to
the clients.

Advantages of client-server computing

The following are some of the benefits of client-server computing:


 All of the required information is stored on a single server. As a result, it's simple to secure data and
provide authorization and authentication.
 It is not necessary for the server to be physically close to the clients. Nonetheless, the data can be
accessed quickly.
 Since all nodes in the client server model are autonomous and only request data from the server, it is
simple to substitute, update, or move them.
 While all nodes, such as clients and servers, are not built on the same platform, they can easily
facilitate data transfer.

Disadvantages of client-server computing

The following are some of the drawbacks of client-server computing:

 If all of the clients request data from the server at the same time, the server can become overloaded.
The network can become congested as a result of this.
 If the server goes down for whatever reason, none of the clients' requests will be fulfilled. This causes
the client-server network to crash.
 Setting up and maintaining a client-server model is very expensive.

Key takes away:

• In client-server computing, a client requests a resource, which the server fulfills


• A request and response framework is used in client-server computing.

Core Java: Introduction, Operator, Data type, Variable, Arrays, Methods & Classes

Introduction

Java is a website as well as a programming language. Java is a high-level programming language that is also
robust, object-oriented, and stable.
Java was created in 1995 by Sun Microsystems (which is now a subsidiary of Oracle). The founder of Java,
James Gosling, is known as the "Father of Java." It was known as Oak before Java. Since Oak was already a
registered company, James Gosling and his team renamed it Java.
Java is an object-oriented programming language that is used to create web and desktop applications. It is
based on classes. It is the most widely used programming language and the preferred language for Android
development.

Operator

Java has a large number of operators for manipulating variables. Many of the Java operators can be divided
into the following categories.
 Arithmetic Operators
 Relational Operators
 Bitwise Operators
 Logical Operators
 Assignment Operators

Arithmetic Operator

In the same way as algebraic operators are used in mathematical expressions, arithmetic operators are used in
mathematical expressions. The arithmetic operators are mentioned in the table below.
Assume integer variable A has a value of 10 and variable B has a value of 20

Relational Operator

The Java language supports the following relational operators.


Assume variable A contains value 10 and variable contains value 5.
Bitwise Operator

Long, int, short, char, and byte are all integer types that can be used with Java's bitwise operators.
The bitwise operator operates with bits and performs operations bit by bit. Assumes variable A contains value
10 and variable contains value 5. So, the binary values of
A0000 1010 and
B0000 0101

Logical Operator
The logical operators are mentioned in the table below.
Assume the Boolean variable A is true and that variable B is false

Assignment Operator
The Java language supports the following assignment operators.
Data types

Data Types in Java are defined as specifies that allocate different sizes and types of values that can be stored
in the variable or an identifier. Java has a rich set of data types. Data types in Java can be divided into two
parts:
 Primitive data type - which include integer, character, boolean, and float
 Non - primitive data type - which include classes, arrays and interfaces.

Primitive Data Types

Primitive Data Types are predefined and available within the Java language. Primitive values do not share
state with other primitive values.
There are 8 primitive types: byte, short, int, long, char, float, double, and boolean Integer data types.
Variable
In Java, a variable is a data container that stores data values during the execution of a Java program. Any
variable is given a data type, which specifies the type and amount of data it can store. The name of the data's
memory location is called a variable. Local, Instance, and Static variables are the three most common types of
Java variables.
To use a variable in a program, you must go through two stages.
Variable Declaration:
You must define the data type and give the variable a unique name when declaring a variable.
Syntax-
Datatype variable_name;
Example-
int num;

Variable Initialization:

You must assign a valid value to a variable before it can be initialized.


num= 50;
Arrays
In most cases, an array is a set of similar-type elements stored in a single memory location.

An array in Java is an object that contains elements of the same data type. Furthermore, the elements of an
array are held in a single memory location. It's a data system where we keep items that are identical. In a Java
array, we can only store a fixed number of elements.

In Java, an array is a dynamically generated class object. The Object class is inherited by Java list, which
implements the Serializable and Clone able interfaces. In Java, we can use an array to store primitive values or
properties. In Java, we can construct single-dimensional or multidimensional arrays in the same way we can in
C/C++.

The first element of an array is stored at the 0th index; the second element is stored at the 1st index, and so on.

Methods & classes


A Java method is a set of statements that are combined to perform a task. When you use the
System.out.println() method to show a message on the console, for example, the system actually executes
multiple statements.
Creating a method
Consider the following example to demonstrate a method's syntax.
Syntax:
public static int methodName (int a, int b)
{
// body
}
Here
 public static-modifier
 int return type
 methodName-name of the method
 a, b-formal parameters
 inta, int b-list of parameters

Classes

A class is a set of objects with similar properties. It's a model or prototype from which things are made. It's a
logical thing. It can't be a physical issue.
In Java, a class may have the following elements:
Fields
Methods
Constructors
Blocks
Nested class and interface
Key takeaway:
• Java is a website as well as a programming language.
• Java is a high-level programming language that is also robust, object-oriented, and stable.
• Java is an object-oriented programming language that is used to create web and desktop applications.
• Java has a large number of operators for manipulating variables.
Dara TV are defined as specifiers that allocate different sizes and types of values that can be stored in the
variable or an identifier
In Java, a
is a data container that stores data values during the execution of a Java program.
• An array in Java is an object that contains elements of the same data type.
• A Java method is a set of statements that are combined to perform a task.
• A class is a set of objects with similar properties. It's a model or prototype from which things are made.

Inheritance

Inheritance is a process in Java that allows one object to inherit all of the properties and behaviors of its parent
object. It is an important component of OOPs.
Inheritance in Java refers to the ability to build new classes that are based on existing ones. When you inherit
from an existing class, you can use the parent class's methods and fields. You can also add new methods and
fields to your current class.
The IS-A relationship, also known as a parent-child relationship, is represented by inheritance.
Basic Terminology
Super class: The term "super class" refers to a class whose characteristics are passed down from generation to
generation (or a base class or a parent class).
Sub class: A subclass is a class that inherits from another class (or a derived class, extended class, or child
class). In addition to the super class fields and methods, the subclass may add its own fields and methods.
Reusability: Inheritance follows the principle of "reusability," which means that if we want to build a new
class but there is already one with some of the code we need, we can derive our new class from the current
one. We're reusing the existing class's fields and methods in this way.
Types of Inheritance
In Java, there are three types of inheritance based on class: single, multilevel, and hierarchical inheritance.
Multiple and hybrid inheritance are only allowed by interfaces in Java programming.
Single Inheritance: Subclasses inherit the characteris
Tics of a single super class in single inheritance. Class A acts as a base class for the derived class B in the
picture below.

Multilevel Inheritance: A derived class inherits a base class in Multilevel Inheritance, and the derived class
also acts as the base class for other classes. Class A serves as a base class for derived class B, which in turn
serves as a base class for derived class C in the diagram below.

Hierarchical Inheritance: One class act as a super class (base class) for multiple subclasses in Hierarchical
Inheritance.
Class A acts as a base class for the derived classes B and C in the diagram below.
Multiple Inheritance: One class can have multiple super classes and inherit features from all parent classes in
multiple inheritances. Please keep in mind that classes in Java do not accept multiple inheritances. Interfaces
are the only way to achieve multiple inheritances in Java. Class C is derived from interfaces A and B in the
diagram below.

Hybrid Inheritance: It's a combination of two or more of the inheritance forms mentioned above. Hybrid
inheritance is not possible with classes because java does not accept multiple inheritances. Interfaces are the
only way to achieve hybrid inheritance in Java.

Key takes away:


Inheritance is a process in Java that allows one object to inherit all of the properties and behaviors of its parent
object.
Inheritance in Java refers to the ability to build new classes that are based on existing ones.
• Subclasses inherit the characteristics of a single superclass in single inheritance.
• A derived class inherits a base class in Multilevel Inheritance, and the derived class also acts as the base
class for other classes.
• One class act as a superclass (base class) for multiple subclasses in Hierarchical Inheritance.
• One class can have multiple super classes and inherit features from all parent classes in multiple
inheritances.
• Hybrid inheritance is not possible with classes because java does not accept multiple inheritances.

Package and Interface


A package is a framework for grouping and controlling access to related types of classes, interfaces, and sub-
packages. It groups classes together into a single unit.
Many predefined packages are already available in Java and can be used when programming.

For example: java.lang, java.io, java.util etc.

Advantages of Package

 Since a package contains a community of classes, it allows for code reuse.


 When several packages have classes with the same name, it aids in resolving naming conflicts.
 The package also includes the ability to hide classes. As a result, other programs would be unable to
use the classes from the secret set.
 With the support of packages, access restrictions may be implemented.
 A package's concept can be found in another package.

Types of Packages

Built in package - The Java API already defines built-in packages. Java.util, java.io, java.lang, java.awt.java.
applet, java.net, and so on are only a few examples.
User defined package - User specified package refers to the package we build based on our requirements.
Creating a package
We can make our own kit by putting together our own classes and interfaces. At the start of the program, the
package statement should be declared.
Syntax
package <packagename>;
class ClassName
{
........
........
}

Interface
 While an interface is similar to a class, it only has abstract methods.
 Variables declared in an interface are by default public, static, and final.
 The interface is a tool for achieving complete abstraction.
There are no constructors in an interface.
Syntax
interface InterfaceName
{
}
public void method():
public void method2();
<type> variableName= value;
Example
interface Employee
{
}
static final Id = 11;
static final String name = "XYZ":
void show ():
void getSalary (double salary);

Extending Interface

As is the case in class, an interface must extend another interface. It is unable to create a new gui.

Implementing Interface

An interface is implemented by a class. The class will then execute the desired behavior on the gui.
When a class implements an interface, it uses the implements keyword.

Syntax
class ClassName implements interface_name
{
// body of class
}

Key takes away:


• A package is a framework for grouping and controlling access to related types of classes, interfaces, and sub-
packages.
• It groups classes together into a single unit.
• Many predefined packages are already available in Java and can be used when programming.
.
While an interface is similar to a class, it only has abstract methods.
The interface is a tool for achieving complete abstraction.

Exception Handling
One of the most essential features of java programming is exception handling, which helps us to manage
runtime errors caused by exceptions.

Exception

An exception is an unintended occurrence that disrupts the program's normal flow. When a program
encounters an exception, it is terminated. In such cases, we receive an error message created by the machine.
Exceptions are useful because they can be managed in Java. We can provide a meaningful message to the user
about the issue instead of a machine produced message, which might not be understandable to a user, by
handling exceptions.
Why Exceptions Occur?
There are many reasons why a program could throw an exception.
For instance, opening a non-existing file in your software, a network connection issue, or incorrect input data
given by the user, to name a few examples.

Exception Handling

If a program encounters an exception that is not addressed by the programmer, the program is terminated and
the user is presented with a system-generated error message.

Example

Exception in thread "main" java.lang. ArithmeticException: /by zero at


ExceptionDemo.main(ExceptionDemo.java:5)
ExceptionDemo: The class name
main: The method name
ExceptionDemo.java: The filename
java:5: Line number

Advantages of Exception Handling

When an exception occurs, exception management guarantees that the program's flow does not interrupt. For
example, if a program contains a large number of statements and an exception occurs in the middle of
executing any of them, the statements following the exception will not be executed, and the program will end
suddenly
Through managing, we ensure that all of the statements are executed and that the program's flow is not
disrupted.

Types of Exception

There are two types of exception


 Checked exception
 Unchecked exception
Checked Exception - Checked exceptions are all exceptions other than Runtime Exceptions that the compiler
tests during compilation to see whether the programmer has treated them or not. Compilation errors can occur
if these exceptions are not handled/declared in the software. SQLException, IOException,
ClassNotFoundException, and so on.

Unchecked Exception - Unchecked Exceptions are another name for Runtime Exceptions. These exceptions
are not tested at compile time, so the compiler has no way of knowing whether the programmer has dealt with
them or not. It is the programmer's duty to deal with these exceptions and have a secure escape.

For example.

ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException etc.

Keywords
In Java, there are five keywords that are used to handle exceptions.
try-The "try" keyword is used to designate a block where exception code should be placed. Either grab or
finally must come after the try block. This means that we can't just use the try block.
catch - To manage the exception, the "catch" block is used. It must be followed by a try block, so we can't just
use catch block. It can be followed by a later finally block.
finally - The "finally block is used to run the program's most significant code. Whether or not an exception is
treated, it is run.
throw-To throw an exception, use the "throw" keyword.
throws - Exceptions are declared using the "throws" keyword. There isn't any exception thrown. It specifies
that an exception can occur in the process. It's often used in conjunction with a method signature.
Key takeaway:
An exception is an unintended occurrence that disrupts the program's normal flow.
• When a program encounters an exception, it is terminated. In such cases, we receive an error message
created by the machine.
.
If a program encounters an exception that is not addressed by the programmer, the program is terminated and
the user is presented with a system-generated error message. Checked exceptions are all exceptions other than
Runtime Exceptions that the compiler tests during compilation to see whether the programmer has treated
them or not.

Multi Thread programming

Since Java is a multi-threaded programming language, we can use it to create multi-threaded programs. A
multi-threaded program is made up of two more parts that can run in parallel, each of which can handle a
different task at the same time, maximizing the use of available resources, particularly when your machine has
multiple CPUs.
In Java, multithreading is the method of running several threads at the same time.
A thread is the smallest unit of processing and is a lightweight sub-process. Multitasking is accomplished by
the use of multiprocessing and multithreading.
Since threads share memory, we use multithreading rather than multiprocessing. They save memory by not
allocating a separate memory field, and context-switching between threads takes less time than processing.
Multithreading in Java is mainly used in sports, animation, and other similar applications.

Advantages of Multithreading

Since threads are separate and several operations can be performed at the same time, it does not cause the user
to be blocked.
It saves time by allowing you to run several operations at once.
Since threads are self-contained, an exception in one thread has no impact on other threads.

Life cycle of Thread


In its life cycle, a thread goes through many phases. A thread, for example, is born, starts, runs, and then dies.
The diagram below depicts a thread's entire life cycle.

The stages of the life cycle are listed below.

New-In the new state, a new thread starts its life cycle. It will stay in this state until the thread is started by the
program. A born thread is another name for it.
Runnable - When a newly created thread is started, it becomes runnable. When a thread is in this state, it is
considered to be doing its job.
Running - If the thread scheduler has picked it, it is in the running state.
Waiting - When a thread is waiting for another thread to complete a job, it will migrate to the waiting state.
Only when another thread signals the waiting thread to begin executing does a thread transition back to the
runnable state.
Dead - When a run able thread completes its task or otherwise terminates, it enters the terminated state.

Key take away:

Since Java is a multi-threaded programming language, we can use it to create multi-threaded programs.
In Java, multithreading is the method of running several threads at the same time.
Multithreading in Java is mainly used in sports, animation, and other similar applications.
1.13 1/0
To process the input and generate the output, Java I/O (Input and Output) is used.
To render I/O operations faster, Java employs the idea of a stream. All of the classes available for input and
output operations are found in the java.io package.

The Java I/O API can be used to handle files in Java.

Stream

A stream is a set of data in a particular order. A stream in Java is made up of bytes. It's called a stream
because it resembles a continuous stream of water.
Three streams are automatically generated for us in Java. The console is connected to both of these streams.
1) System.out:standard output stream
2) System.in: standard input stream
3) System.err: standard error stream
Java Applet

An applet is a type of Java program that runs in a browser that supports Java. This is the first Java program
that can run in a browser over a network. An applet is a web application that runs in the browser and is usually
embedded inside a web page.

Applets, in other words, are small Java programs that can be accessed on an Internet server, transported over
the Internet, and installed and run automatically as part of a web document.
When a user receives an applet, the applet will generate a graphical user interface for that user. It has
restricted access to resources so that it can perform complicated calculations without the risk of introducing
viruses or compromising data integrity.
A class that extends java. applet is required to build an applet. Applet is a kind of applet.
There is no main() method in an Applet class. JVM is used to view it. To run an applet program, the JVM can
use either a Web browser plug-in or a separate runtime environment.
To initialize
Applet, JVM creates an instance of the applet class and calls the init() method.
Life cycle of java Applet
The phases of Applet are as follows:
• Applet is initialized.
.Applet is started
• Applet is painted.
• Applet is stopped.
• Applet is destroyed.
Key takes away:
An applet is a type of Java program that runs in a browser that supports java.
This is the first Java program that can run in a browser over a network.
An applet is a web application that runs in the browser and is usually embedded inside a web page.

String handling, Event handling

The basic goal of the String Handling principle is to store string data in main memory (RAM), manipulate
string date, retrieve part of the String, and so on. String Handling includes a variety of definitions that can be
applied to a string, such as string concatenation, string comparison, and finding substrings
An immutable series of Unicode characters is contained in a Java String. The difference between a Java String
and a string in C or C++ is that a string in C or C++ is simply an array of char. The java.lang package contains
the String class.
Immutable class in Java
The term "immutable class" refers to the fact once an object is made, its content cannot be changed. In Java,
you should. All wrapper classes in Java, including String, Integer, Byte, Short, Flost, Double, and others, are
immutable.

String
String is described as a sequence of characters enclosed in double quotes ("").
Example:"web technology"
A fundamental data type called char is used in web technology to store character data. Similarly, we have
three predefined classes for storing string data and performing various operations on string data: String
.
String Bulle
StringBuilder

Creating a string object


A string object can be generated in a variety of ways, here are a few examples
Using a string literal-A plain string enclosed in double quotes" "is referred to as a string literal. A String
object is created from a string literal

2. Using new keyword-The new operator, which allocates memory for the object, can be used to generate a
new string object.
Concatenating string

There are 2 methods to concatenate two or more strings


Using concat() methed
Using + operator
String comparison
To compare string objects, Java provides methods and operators both. So, we can compare strings in the
following three ways.
Using quals() method
Using operater
.By CompareTo() method
Event handling
An occurrence occurs when the state of an entity changes. For instance, clicking a button, dragging the mouse,
and so on. For event management, the java.awt.event package offers a number of event classes and Listener
interfaces.
Event class and listener interface

Steps to perform event handling

To handle a case, you must take the following steps


The part must be registered with the Listener.
Registration methods
Many classes have registration methods for registering the part with the Listener.
Consider the following scenario:
Button
= public void addActionListener (ActionListener a)
MenuItem
= public void addActionListener (ActionListener a) {} TextField
= public void addActionListener (ActionListener a)
= public void addTextListener (TextListener a) {}
TextArea
= public void addTextListener (TextListener a) {} Checkbox
= public void addItemListener (ItemListener a) {}
Choice
= public void addItemListener (ItemListener a) {}
List
= public void addActionListener (ActionListener a) {}
= public void addItemListener (ItemListener a) {}

Key takeaway:
The basic goal of the String Handling principle is to store string data in main memory (RAM), manipulate
string data, retrieve part of the String, and so on. • String Handling includes a variety of definitions that can be
applied to a string, such as string concatenation, string comparison, and finding substrings.
Introduction to AWT

Java AWT (Abstract Window Toolkit) is a Java API for creating graphical user interface (CUI) or window-
based applications. The Java AWT API is a set of classes and methods for creating and managing graphical
user interface (CUI) applications
The AWT was created to provide a standardized collection of tools for creating graphical user interfaces that
could be used on a number of platforms. The AWT tools are implemented using the native CUI toolkit of each
platform, retaining the look and feel of each platform. This is one of the benefits of using AWT.
However, the drawback of this approach is that when a GUI is configured for one platform, it can appear
differently when viewed on another platform, implying that AWT components are platform based.
TextField, Label, TextArea, RadioButton, CheckBox, Choice, List, and other AWT api classes are available in
the java.awt package.
Swing is built on top of the AWT framework, Swing is an enhanced CUI API that expands the AWT.
However, nowadays, AWT is only used because most CUI Java programs are written in Swing, which has a
rich set of CUI controls and is lightweight

Key takes away

Java AWT (Abstract Window Toolkit) is a Java API for creating graphical user interface (CUI) or window-
based applications.
The Java AWT API is at of class and methods for creating and managing graphical user interface (GUI)
applications.
The AWT was created to provide a standardized collection of tools for creating graphical user interfaces that
could be used on a number of platforms.

AWT controls

The user can communicate with the application using AWT controls, such as the TextField control, which
allows the user to enter any message
Layout Managers create templates that automatically place controls within containers. Well use Applet as a
container in this chapter. Applet comes with Flow Layout by default.
AWT Control
The following central groups are available in AWT
Label
Button
Checkbox
TextAre
Chaise (Drop Down List)
Scrollbar
All of these groups are Component's children (subclasses).
Label
A label is a graphical user interface control that displays static text. The Label class and its constructors,
which are described below, can be used to build a label: Label()
Label (String)
Labeling in haw)

Button
The most popular CUI control is a push button. The Button class and its constructors can be used to build a
push button or a button, as shown below
Button 0
Button (Bring)
Checkbox
The Checkbox class and its constructors can be used to generate a checkbox control:
Checkbox()

Checkbox (ring atz)


Checkboxing at Boolean on)
Checkbox (String str, boolean on, CheckboxCroup ob Croup)
Checkbox (String str. CheckboxGroup cb Croup, boolean on)

Drop Down list

A drop-down box, also known as a combination box, displays a list of options (strings). When a user selects
an object from a drop-down box, a list of options appears from which the user can choose one.
The Choice class can be used to build a drop-down box. The option class has only one constructor that can be
used to gener
Liat
A List box displays a list of options from which the user can choose one or more. The user can see more than
tbox. The List class and the following constructors can be used to build a list b
List (int numRows)
List (int numRows, boolean multipleSelect)
Text field
as a text box, is a single-line text entry control that enables the user to ty
of text. The TextField class, along with its constructors, can be used to build a text field:
TextField()
TextField(int numChara
Tild(String atz)
TextField(String str, int numChars)
Text Ares
A multi-line entry control that allows a user to type:
TextArea()
Tumlines, in numChara)
Tres (Bringar)
TextArea (String str, int numlines, int numChara)
Tr(String in minint numChars, in Bara)
The TextArea class and the following constructor can be used to build a text area:
numLines specifies the text area's height, numChars specifies the text area's width, at specifies the t tarea's
initial text, and Bars specifies the scroll bars in the constructors above
Kayak
.The user can communicate with the application using AWT controls, such as the TextField control, which
allows the user to enter any massage. The most popular GUI central is a push button.
Axtarea is a multi-line text entry control that allows a user to type several lines of text.
.Attfield also known as a text box is a single-line text entry control that enables the user to type only one line
of text
Layout managers
Layout Managers are used to organize components in a specific way. The interface Layout Manager is applied
for all types of layout managers.

The layout managers are described by the following classes:


.java.awt.BorderLayout
java.awt.FlowLayout
.java.awt.GridLayout
java.awt.CardLayout
java.awt.GridBagleyout javax.swing Bedayout
javax.swing GroupLayout
javax.swing ScrollPaneLayout javax.swing SpringLayouts

Border Layout

The Border Layout is used to divide the components into Eve different regions: north, south, east, eat, and
middle. Only one component can be present in each region (area). That is the standard frame or window
arrangement. For each field, the Border Layout provides five constanta: public static final int NORTH
public static final int SOUTH
public static final int EAST
public static final in WEST
public static final int CENTER

Gridbag Layout

Components may be aligned vertically, horizontally, or along their baseline using the Java GridBagLayout
class.
It's possible that the components aren't all the same size. A dynamic, rectangular grid of cells is maintained by
each GridBagLayout object. Each portion has a display area that consists of one or more cells.
GridBagConstraints is associated with each component. We use the constraints object to organize the display
area of the part on the grid. In order to decide component size, the GridBagLayout manages each component's
minimum and desired sizes.
Box Layout

The Box Layout is used to vertically or horizontally organize the elements. Box Layout offers four constants
for this reason. The following are the details:
public static final int X_AXIS
public static final intY AXIR
public static final int LINE AXIS
public static final int PACE AXIS

Construction

Box Layout (Container c, int axis): creates a box arrangement with the specified axis that arranges the
components.

Layout Managers are used to organize components in a specific way


The intrine Layout Manager is applied for all types of layout managers.
The Border Layout is used to divide the components into five different regions: north, south, wast, west, and
middle.
The Flow Layout is used to line up the components one after another in a line.
The CridLayout is used to make a rectangular grid out of the components. Each rectangle displays a single
part.
The CardLayout class organizes the components such that only one is available at any given time.
Components may be aligned vertically, horizontally, or along their baseline using the Java CridBagLayout
class.
The BoxLayout is used to vertically or horizontally organize the elements.

You might also like