0% found this document useful (0 votes)
4 views1 page

Serv Let

A servlet is a technology for creating web applications, functioning as an API with interfaces and classes, and requiring implementation for servlet creation. Unlike CGI, which creates a new process for each request, servlets use threads, making them more efficient and platform-independent. The servlet life cycle includes loading the servlet, creating an instance, initializing, servicing requests, and finally destroying the servlet.

Uploaded by

MRIGAANK JASWAL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Serv Let

A servlet is a technology for creating web applications, functioning as an API with interfaces and classes, and requiring implementation for servlet creation. Unlike CGI, which creates a new process for each request, servlets use threads, making them more efficient and platform-independent. The servlet life cycle includes loading the servlet, creating an instance, initializing, servicing requests, and finally destroying the servlet.

Uploaded by

MRIGAANK JASWAL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Servlet

servlet can be described in many ways depending on the context


- it is a tech which is used to create a web application
- it is an API that provides many interfaces and classes including documentations
- it is an interface that must be implemented for creating any servlet
- it is a class that extends

client -> request -> server -> response is generated at runtime -> response is sent
to the client

Before this we have CGI (common gateway interface)


it enables the web server to call an external program and pass HTTP request
information to the program to process the request.
For each request and make new CGI for new request increase space and it starts a
new process to create a new process we need a lot of space and computation power

Disadvantages -
1. if number of client increase it takes more time for sending the response
2. Platform dependent for C/C++

advantages of servlet -
- instead of creating new servlet it will make the thread instead of the new
process
- it is platform independent

HTTP requests
1. GET
2. Post
3. HEAD
4. TRACE
5. PUT
6. DELETE

Life cycle of a Servlet (servlet life cycle)


1. Servlet class is loaded
2. Create the servlet instance (it is created only once when user sends the
request)
3. call the init() method [CREATE STATE]
4. call the service() method [READY STATE] - we can perform all the HTTP
requests .
5. call the destroy() method [END STATE] - After service we will destroy this .

<% java src code %> it is known as script let tag


<%="expression" %> it is used to print the expression
<%! int a = 50;%> we can declare variables and methods

java beans -
it is just a simple class , if some class follows following properties then it is
called a java bean class
1. Public class
2. No argument constructor
3. Data Encapsulation - private data members
4. Getter and Setter

Project -
1. Fetch record in the table Employee table (id ,name, email)
2. intermediate class - Data access object Layer between database and controller
3. com.employee.classes
4. In webapp create jsp files -> index, search , list

You might also like