0% found this document useful (0 votes)
6 views

Java Notes

Uploaded by

dolar45755
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Java Notes

Uploaded by

dolar45755
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

JAVA NOTES

History of Java 💻
Java was written by James Gosling along with Mike Sheridan and Patrick
Laughton while they were working at Sun Microsystems. Initially, it was named
Oak Programming Language. The Java team members, also known as the Green
Team, initiated a revolutionary task to develop a language for digital devices such
as set-top boxes, televisions, etc.

What is Java? 🤔
Java is a programming language and a platform. Java is a high-level, object-
oriented programming language.

Features of Java 🎉
1. Simple

Java is easy to learn and its syntax is quite simple, lean, and
easy to understand.

2. Object-Oriented

In Java, everything is an object which encapsulates some data


and behavior.

3. Robust

Java makes an effort to eliminate error-prone codes by


emphasizing mainly on compile-time error checking and
runtime checking.

JAVA NOTES 1
4. Platform Independent

Unlike other programming languages such as C, C++ etc.,


which are compiled into platform-specific machines, Java is
guaranteed to be write-once, run-anywhere.

5. Secure

When it comes to security, Java is always the first. Java secure


features enable us to develop virus-free systems.

6. Multi-Threading

Java's multithreading feature makes it possible to write


programs that can do many tasks simultaneously.

7. Architectural Neutral

Compiler generates an intermediate code which has nothing to


do with a particular architecture, hence a Java program is easy
to interpret on any machine.

8. Portable

Java Byte code can be carried to any platform. No


implementation-dependent features. Everything related to
storage is predefined.

9. High Performance

Java is an interpreted language, so it will never be as fast as a


compiled language like C or C++. But Java enables high

JAVA NOTES 2
performance with the use of just-in-time compilation.

JVM and its Architecture 🤖


JVM (Java Virtual Machine)

Java Virtual Machine (JVM) is a virtual machine that provides a


runtime environment to execute Java bytecode.

JVM Architecture:
Component Description

Class Loader Loads the class for execution.

Method Area Stores pre-class structure as a constant pool.

Heap Heap is where objects are allocated.

Local variables and partial results are stored here. Each thread has a
Stack
private JVM stack created when the thread is created.

Program register holds the address of JVM instruction currently


Program Register
being executed.

Native Method
It contains all native methods used in the application.
Stack

Execution engine controls the execution of instructions contained in


Execution Engine
the methods of the classes.

Native Method Native method interface gives an interface between Java code and
Interface native code during execution.

Native Method Native libraries consist of files required for the execution of native
Libraries code.

Difference between JDK, JRE, and JVM 🤔


Term Description

JVM JVM (Java Virtual Machine) is an abstract machine. It is a specification


that provides a runtime environment, in which Java bytecode can be

JAVA NOTES 3
executed.

JRE is an acronym for Java Runtime Environment. It is used to provide a


JRE
runtime environment. It is the set of libraries that JVM uses at runtime.

JDK is an acronym for Java Development Kit. It physically exists. It


JDK
contains JRE + development tools.

Java Operators 💻
1. Arithmetic Operators

Java provides all the basic arithmetic operators.

2. Relational Operators

Relational operators are used to compare two quantities.

3. Assignment Operators

Assignment operators are used to assign the value of an


expression to a variable.

4. Increment and Decrement Operators


Java has two very useful operators not generally found in many
other languages. These are increment and decrement
operators ++ and --.

5. Conditional Operators

The character pair ?: is a ternary operator available in Java.


This operator is used to construct conditional expressions.

JAVA NOTES 4
6. Bitwise Operators

Java has a set of special operators for manipulation of data at


the bit level.

Application of Java 💼
Java is being used in:

Real-time Systems • Simulation and Modelling • Object-oriented Databases •


Artificial Intelligence and Expert Systems • CIM/CAD/CAM Systems • Neural
Networks and Parallel Programming • Decision Support Systems

Arrays in Java 📊
What is an Array?

An array is one type of data structure in Java.## Arrays in Java


📚
Arrays are variables that store multiple values of the same data type. They can
have many dimensions, such as one-dimensional, two-dimensional, or
multidimensional.

One-Dimensional Array
The general form to declare a one-dimensional array is:

Datatype array_variable_name[];

Here, Datatype can be any data type, and array_variable_name is the name of the
array.
Example:

int intArray[];

JAVA NOTES 5
This declares an array of integers.

Multidimensional Array
A multidimensional array displays values in the form of rows and columns, like a
table. It is also known as an array of arrays.

Example:

int[][] multidimensionArray = new int[2][3];

This declares a two-dimensional array with 2 rows and 3 columns.

Control Structures in Java 🚀


Control structures determine the order in which statements are executed in a Java
program.

Conditional Control Structure


If Statement:

If statements are used to execute a block of code if a certain


condition is true.

Syntax:

if (condition) {
statements
}

Example:

if (x > 0) {
System.out.println("Positive");
}

JAVA NOTES 6
If-Else Statement:

If-else statements are used to execute a block of code if a


certain condition is true, and another block of code if the
condition is false.

Syntax:

if (condition) {
statements
} else {
statements
}

Example:

if (x > 0) {
System.out.println("Positive");
} else {
System.out.println("Not Positive");
}

If-Else-If Statement:

If-else-if statements are used to execute a block of code if a


certain condition is true, and another block of code if the
condition is false, and another block of code if another
condition is true, and so on.

Syntax:

if (condition1) {
statements
} else if (condition2) {

JAVA NOTES 7
statements
} else {
statements
}

Example:

if (x > 0) {
System.out.println("Positive");
} else if (x < 0) {
System.out.println("Negative");
} else {
System.out.println("Zero");
}

Switch Statement:

Switch statements are used to execute a block of code based


on the value of a variable.

Syntax:

switch (variable) {
case constant1:
statements
break;
case constant2:
statements
break;
default:
statements
}

Example:

JAVA NOTES 8
switch (k) {
case 0:
System.out.println("Equal");
break;
case 1:
System.out.println("Not Equal");
break;
default:
System.out.println("Unknown");
}

Jumping Control Structure


Break Statement:

Break statements are used to exit a loop or switch statement.

Example:

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


if (i == 5) {
break;
}
System.out.println("Hello");
}

Labelled Break Statement:

Labelled break statements are used to exit a labelled loop.

Example:

ABC:
for (i = 1; i <= 10; i++) {
for (j = 1; j <= 10; j++) {

JAVA NOTES 9
if (j == 5) {
break ABC;
}
System.out.println("Hello");
}
}

Continue Statement:

Continue statements are used to skip the current iteration of a


loop.

Example:

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


if (i == 5) {
continue;
}
System.out.println("Hello");
}

Labelled Continue Statement:

Labelled continue statements are used to skip the current


iteration of a labelled loop.

Example:

XYZ:
while (true) {
while (true) {
if (i < 2) {
continue XYZ;
}
System.out.println("Hello");

JAVA NOTES 10
break XYZ;
}
}

Return Statement:

Return statements are used to exit a method and return a value.

Example:

int sum(int a, int b) {


return a + b;
}

Iterative Control Structure (Loops)


For Loop:

For loops are used to execute a block of code repeatedly for a


specified number of iterations.

Syntax:

for (initialization; condition; increment/decrement) {


statements
}

Example:

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


System.out.println("Hello");
}

While Loop:

JAVA NOTES 11
While loops are used to execute a block of code repeatedly
while a certain condition is true.

Syntax:

while (condition) {
statements
}

Example:

i = 1;
while (i <= 10) {
System.out.println("Hello");
i++;
}

Do-While Loop:

Do-while loops are used to execute a block of code repeatedly


while a certain condition is true. The loop will execute at least
once.

Syntax:

do {
statements
} while (condition);

Example:

i = 1;
do {
System.out.println("Hello");

JAVA NOTES 12
i++;
} while (i <= 10);

For-Each Loop:

For-each loops are used to execute a block of code for each


element in an array or collection.

Syntax:

for (variable : array/collection) {


statements
}

Example:

int[] x = {10, 20, 30};


for (int k : x) {
System.out.println(k + 5);

📚
}
```## Classes and Objects

**Class**: A blueprint or template that defines the propertie


s and behavior of an object.

**Object**: An instance of a class, which represents a real-w


orld entity or concept.

### Constructors

A **constructor** is a special method that is used to initial


ize an object. Every class has a constructor, and if you do
n't explicitly define one, the compiler will build a default
constructor for that class. A constructor has the same name a
s the class and cannot be abstract, static, or synchronized.

JAVA NOTES 13
#### Types of Constructors

* **Default Constructor**: A constructor with no parameters.


* **Parameterized Constructor**: A constructor with one or mo
re parameters.

### Constructor Overloading

**Constructor Overloading** is when multiple constructors wit


h different signatures are defined in a class. This allows fo
r objects to be created with different initial states.

## Access Modifiers in Java 🔒


**Access Modifiers** specify the accessibility (scope) of a d
ata member, method, constructor, or class. There are four typ
es of access modifiers in Java:

| Access Modifier | Within Class | Within Package | Outside P


ackage | Outside Package (Inheritance) |

✔️ ❌ ❌ ❌
| --- | --- | --- | --- | --- |

✔️ ✔️ ❌ ❌
| **Private** | | | | |

✔️ ✔️ ✔️ ✔️
| **Default** | | | | |
| **Protected** | | | (Inheritance) | (Inheritanc

| **Public** | ✔️ | ✔️ | ✔️ | ✔️ |
e) |

### Keywords in Java

**Keywords** are special tokens in the language that cannot b


e used as identifiers. Here are some keywords in Java:

* `abstract`
* `assert`
* `boolean`

JAVA NOTES 14
* `break`
* `byte`
* `case`
* `catch`
* `char`
* `class`
* `const`
* `continue`
* `default`
* `do`
* `double`
* `else`
* `enum`
* `extends`
* `final`
* `finally`
* `float`
* `for`
* `goto`
* `if`
* `implements`
* `import`
* `instanceof`
* `int`
* `interface`
* `long`
* `native`
* `new`
* `package`
* `private`
* `protected`
* `public`
* `return`
* `short`
* `static`
* `strictfp`

JAVA NOTES 15
* `super`
* `switch`
* `synchronized`
* `this`
* `throw`
* `throws`
* `transient`
* `try`
* `void`
* `volatile`
* `while`

## Inheritance in Java 👪
**Inheritance** is a mechanism in which one class can inherit
the properties and behavior of another class. Inheritance is
implemented using the `extends` and `implements` keywords.

### Types of Inheritance

* **Single Inheritance**: A class inherits properties and beh


avior from a single parent class.
* **Multiple Inheritance** (Through Interface): A class inher
its properties and behavior from multiple parent interfaces.
* **Multilevel Inheritance**: A class inherits properties and
behavior from a parent class, which in turn inherits from ano
ther parent class.
* **Hierarchical Inheritance**: A class inherits properties a
nd behavior from multiple parent classes.
* **Hybrid Inheritance**: A combination of multiple and multi
level inheritance.

## Purpose of Inheritance 🤔
* For **Method Overriding** (to achieve runtime polymorphis
m).

JAVA NOTES 16
* For **Code Reusability**.

### Method Overloading vs Method Overriding

| | Method Overloading | Method Overriding |


| --- | --- | --- |
| **Definition** | Multiple methods with same name but differ
ent parameters | A method with same name, return type, and pa
rameters as a method in its parent class |
| **Purpose** | To provide multiple ways to perform an operat
ion | To provide a specific implementation for a method in a
child class |
| **Parameter** | Different | Same |
| **Return Type** | Same or different | Same |

🤔
| **Access Modifier** | Same or different | Same or more perm
issive |## What is an Applet?

An applet is a Java program that runs in a Web browser. It is


a fully functional Java application, but with some difference
s from a standalone Java application.

### Key Differences

* An applet is a Java class that extends the `java.applet.App


let` class.
* A main method is not invoked on an applet, and an applet cl
ass will not define a main method.
* Applets are designed to be embedded within HTML pages.
* When a user views an HTML page that contains an applet, the
code for the applet is downloaded to the user's machine.
* A JVM (Java Virtual Machine) is required to run an applet.
The JVM can be a plug-in of the Web browser or a separate run
time environment.

### How to Run an Applet

JAVA NOTES 17
There are two ways to run an applet:

* By HTML file
* By AppletViewer tool (for testing purposes)

### Example of Applet By HTML File

To execute the applet by HTML file, create an applet and comp


ile it. After that, create an HTML file and place the applet
code in the HTML file. Now click the HTML file.

**Applet Code:**
```java
import java.applet.Applet;
import java.awt.Graphics;

public class First extends Applet {


public void paint(Graphics g) {
g.drawString("welcome", 150, 150);
}
}

HTML Code:

<html>
<body>
<applet code="First.class" width="300" height="800"></app
let>
</body>
</html>

Example of Applet By AppletViewer Tool


To execute the applet by AppletViewer tool, create an applet that contains an
applet tag in the comment and compile it. Now HTML file is not required, but it is

JAVA NOTES 18
for testing purposes only.

Applet Code:

import java.applet.Applet;
import java.awt.Graphics;

public class First extends Applet {


public void paint(Graphics g) {
g.drawString("welcome to applet", 150, 150);
}
}

Command to Run Applet:

javac First.java
appletviewer First.java

Life Cycle of an Applet 📈


The life cycle of an applet consists of the following methods:

init() method

start() method

paint() method

stop() method

destroy() method

Description of Life Cycle Methods

The init() method is the starting point of the applet. It is called


when the applet is created by the browser. The programmer
can utilize this method to instantiate objects, initialize variables,
set background and foreground colors in GUI, etc.

JAVA NOTES 19
The start() method makes the applet active and thereby eligible
for processor time.

The paint() method takes a Java Graphics object as a


parameter. This class includes many methods of drawing
necessary to draw on the applet window.

The stop() method makes the applet temporarily inactive. An


applet can come into this method any number of times in its life
cycle and can go back to the active state (paint() method)
whenever like.

The destroy() method is called just before an applet object is


garbage collected. This is the end of the life cycle of the
applet.

Advantages and Disadvantages of Applet 💡


Advantages
Simple to make it work on Linux, Microsoft Windows, and OS X i.e‫ شمالی‬to
make it cross-platform.

The same applet can work on all installed versions of Java at the same time,
rather than just the latest plug-in version only.

Most web browsers cache applets so will be quick to load when visiting a web
page.

Can move the work from the server to the client, making the web solution
more scalable with the number of users/clients.

If a standalone program (like Google Earth) talks to a server, that server


normally needs to support all prior versions of users which have not kept their
client software updated.

JAVA NOTES 20
Disadvantages
Requires the Java plug-in.

Some browsers, notably mobile browsers running on iOS or Android, do not


run Java applets at all.

Some organizations only allow software installed by administrators.

As with any client-side scripting, security restrictions can make it difficult or


even impossible for an untrusted applet to achieve certain tasks.

Difference between Applet and Application ⚖️


Applet Application

Small program Large program

Used to run a program on a client Used to run a program on a standalone computer


browser system

Portable and can be executed by any


Can access all the resources of the computer
supported browser

Restricted resources of the computer No restrictions on resources

5 methods which will be automatically


invoked on occurrence of specific Single start point which is main method
events

Example: import java.applet.*; Example: public class MyClass { public static


public class Myclass extends Applet void main(String args[]) { ... } } ## Event
{ ... } Handling in Java 🎉
Event Handling is the mechanism that controls the flow of events and decides
what should happen when an event occurs.

Delegation Event Model


The Delegation Event Model is a standard mechanism for generating and handling
events in Java. It consists of the following key components:

Source: The source is an object on which an event occurs. The source is


responsible for providing information about the occurred event to its handler.

JAVA NOTES 21
Listener: A listener is also known as an event handler. It is responsible for
generating a response to an event. From an implementation point of view, the
listener is also an object.

Event: An event is an occurrence that triggers a response from the listener.

How Events are Handled


1. A source generates an event.

2. The event is sent to all listeners registered with the source.

3. Each listener processes the event and returns a response.

Java Packages for Networking


Java provides several packages for networking, including:

java.net : Contains classes and interfaces for network programming.

java.nio : Contains classes and interfaces for buffer-oriented I/O operations.

Socket Programming in Java


Socket provides the communication mechanism between two computers using
TCP/IP. A socket is created on the client side and attempts to connect to a server.
When a connection is made, the server creates a socket object on its end of the
communication. The client and server can now communicate by writing to and
reading from the socket.

JDBC in Java
JDBC stands for Java Database Connectivity, which is a standard Java API for
database-independent connectivity between the Java programming language and
a wide range of databases.

JDBC Architecture
JDBC architecture consists of two layers:

JDBC API: This provides the application-to-JDBC Manager connection.

JAVA NOTES 22
JDBC Driver API: This supports the JDBC Manager-to-Driver connection.

JDBC Components
The JDBC API provides the following interfaces and classes:

DriverManager: Manages a list of database drivers.

Connection: Represents a connection to a database.

Statement: Used to submit SQL statements to the database.

ResultSet: Holds data retrieved from a database.

SQLException: Handles any errors that occur in a database communication.

HTML Basics
HTML stands for HyperText Markup Language, which is used to create electronic
documents (called pages) that are displayed on the World Wide Web.

HTML Tags
An HTML tag is a code that describes how a Web page is structured and
displayed. HTML tags are defined by the characters < and > .

Here are some common HTML tags:

Tag Description
<a> Anchor tag creates a link to other internet locations or files.

Abbreviation tag indicates the interpretation of the meaning to the


<abbr>
browsers and search engines.

Address tag is used to identify the author's contact information for a


<address>
section or a document.
<applet> Applet tag is used to embed a Java application within an HTML page.

Difference between HTML and HTML5


Here are some key differences between HTML and HTML5:

Feature HTML HTML5

JAVA NOTES 23
Audio and
Not part of the specification Part of the specification
Video

Possible with the help of


Vector Integral part of HTML5 with SVG and
technologies like VML,
Graphics canvas
Silverlight, Flash etc.

Almost impossible to get true Helps identify location of user with the
Geolocation
geolocation of user help of JS Geolocation API

Application Cache, Web SQL database,


Can be used as temporary
Browser Cache and Web storage are available as
storage
client-side storage

Full-duplex communication channels


Web Sockets Not available can be established with the server
using Web Sockets

BLOCKQUOTE
BLOCKQUOTE tags are used to separate a section of text from
the surrounding text.

B and I Tags
B tags define bold text.

I tags define italic text.

HTML Structure 🗂️
<html>
<head>
<!-- Head content -->
</head>
<body>
<!-- Body content -->
</body>
</html>

📊
JAVA NOTES 24
Table Tags 📊
COL Tags
COL tags define column properties for a table.

COLGROUP Tags
COLGROUP tags define groups of table columns.

TABLE Tags
TABLE tags define a table.

TR Tags
TR tags define a table row.

TD Tags
TD tags define a table data cell.

Other HTML Tags

BUTTON Tags
BUTTON tags create a clickable button.

CAPTION Tags
CAPTION tags add a caption to a table.

CENTER Tags
CENTER tags center text, images, etc.

CODE Tags
CODE tags are used to indicate a code snippet.

JAVA NOTES 25
DD Tags
DD tags define a definition description.

DIR Tags
DIR tags define a directory list.

DL Tags
DL tags define a definition list.

DFN Tags
DFN tags emphasize a definition.

DIV Tags
DIV tags define a logical section of a web document.

HEAD Tags
HEAD tags contain metadata about the document.

Servlets 🚀
Definition

Servlets are programs that run on a web or application server


and act as a middle layer between a request coming from a
web browser or other HTTP client and databases or
applications on the HTTP server.

Advantages over CGI


Performance is significantly better.

Servlets execute within the address space of a web server.

JAVA NOTES 26
Servlets are platform-independent because they are written in Java.

Java security manager on the server enforces a set of restrictions to protect


the resources on a server machine.

The functionality of the Java class libraries is available to a servlet.

Architecture
HTTP Server
|
| HTTP Protocol
|
| Web Browser
|
| Servlet
|
| Database/Application

Servlet Tasks
Read the explicit data sent by the clients (browsers).

Read the implicit HTTP request data sent by the clients (browsers).

Process the data and generate the results.

Send the response back to the client.

Servlet Life Cycle


1. Servlet class is loaded.

2. Servlet instance is created.

3. init method is invoked.

4. service method is invoked.

5. *destroy method is invoked.Here is the study guide:

🌟
JAVA NOTES 27
Servlets and JSP 🌟
Creating a Servlet Example
To create a servlet example, there are 6 steps:

Create a directory structure

Create a Servlet

Compile the Servlet

Create a deployment descriptor

Package and deploy the Servlet

Test the Servlet

Servlet Interface
The Servlet interface provides methods that all Servlets must implement. These
methods are:

Method Description
init() Initialize the Servlet
service() Handle client requests
destroy() Clean up resources

HTTP Request Methods


HTTP request methods are used to interact with a server. The 7 HTTP request
methods are:

GET: Asks to get the resource at the requested URL

POST: Asks the server to accept the body info attached

HEAD: Asks for only the header part of what GET would return

PUT: Says to put the enclosed entity at the requested URL

DELETE: Says to delete the entity at the requested URL

JAVA NOTES 28
OPTIONS: Asks for a list of the HTTP methods to which the thing at the
requested URL can respond

TRACE: Asks for the loopback of the request for testing or troubleshooting

Difference between GET and POST


GET POST

Not saved in browser


Parameters Saved in browser history
history

Bookmarkable Can be bookmarked Cannot be bookmarked

Executable Can be re-executed May not be re-submitted

Limited to what can be stored in the request No restrictions on form


Data
line (URL) data

Security Less secure More secure

JSP (Java Server Pages) 🌊


JSP is a technology used to create web applications. It is an extension to Servlet
technology and provides more functionality such as expression language, JSTL,
and custom tags.

Features of JSP
Extension to Servlet: JSP is an extension to Servlet technology

Powerful: JSP consists of bytecode, so all Java features are applicable

Portable: JSP tags are processed and executed by the server-side web
container, so they are browser-independent and J2EE server-independent

Flexible: Allows defining custom tags

Easy to learn: Easier to learn and understand than Servlets

Less code than Servlet: Reduces code using tags such as action tags, JSTL,
and custom tags

Elements of JSP

JAVA NOTES 29
There are 5 different types of scripting elements in JSP:

Scripting Element: Written inside <% %> tags

Comment: Written inside <%-- --%> tags

Directive: Written inside <%@ %> tags

Declaration: Written inside <%! %> tags

Expression: Written inside <%= %> tags

Let me know if you'd like me to add anything else! 😊## JSP Fundamentals 📚
JSP Comments
JSP comments are used to add notes about the code within a JSP page. They are
only visible in the JSP page and are not included in the servlet source code during
translation. They do not appear in the HTTP response.

"JSP comments are used to add notes about the code within a
JSP page."

Syntax: <%-- JSP comment --%>

Scriptlet Tag
The Scriptlet Tag allows you to write Java code inside a JSP page.

"Scriptlet Tag is used to write Java code inside a JSP page."

Syntax: <% java code %>

Example

<html>
<head>
<title>My First JSP Page</title>
</head>
<body>
<%

JAVA NOTES 30
int count = 0;
out.println(++count);
%>
</body>
</html>

Declaration Tag
The Declaration Tag is used to declare variables or methods. It is similar to
declaring a variable or method in a Java class.

"Declaration Tag is used to declare variables or methods."

Syntax: <%! declaration %>

Example

<html>
<head>
<title>My First JSP Page</title>
</head>
<body>
<%!
int count = 0;
%>
Page Count is: <%= ++count %>
</body>
</html>

Expression Tag
The Expression Tag is used to print the value of a Java expression.

"Expression Tag is used to print the value of a Java


expression."

JAVA NOTES 31
Syntax: <%= expression %>

Example

<html>
<head>
<title>My First JSP Page</title>
</head>
<body>
The result is: <%= 2*5 %>
</body>
</html>

Directive Tag
The Directive Tag is used to define page-dependent properties.

"Directive Tag is used to define page-dependent properties."

Syntax: <%@ directive %>

Example

<%@ page import="java.util.*" %>

JSP Architecture 🏢
JSP is part of a 3-tier architecture:

Client Browser: sends the request to the web server

Web Server: receives the request and passes it to the JSP engine

Database: stores the data

The JSP architecture flow is as follows:

1. The user makes a request to a JSP page via the internet in their web browser.

2. The JSP request is sent to the web server.

JAVA NOTES 32
3. The web server accepts the requested .jsp file and passes it to the JSP
engine.

4. The JSP engine translates the JSP file into a servlet.

5. The servlet output is sent via the internet to the user's web browser.

6. The HTML results are displayed on the user's browser.

Setting up JSP Environment 🔧


To set up a JSP environment, you need to:

Download and Install Java: download the latest version of Java SE from
Oracle's website and install it on your system.

Download and Install Apache Tomcat: download the latest version of Apache
Tomcat from the Apache website and install it on your system.

Here are the steps to install Java and Tomcat on Windows:

Step Java Installation Tomcat Installation

Download Java SE from Download Apache Tomcat from the


1
Oracle's website Apache website

Run the downloaded .exe file


Run the downloaded .exe file and follow
2 and follow the installation
the installation wizard
wizard

Default installation location is C:\Program


Default installation location is
3 Files\Apache Software
C:\Java\jdk<version>
Foundation\Tomcat<version>

Note: Make sure to set the environment variables for Java and Tomcat after
installation.

JAVA NOTES 33

You might also like