Skip to main content

Amazon Ads

How Java Servlet Works?

Features of Java Servlet

There are 5 Features of Servlet are as Follow:
Portable: Servlet uses Java Programming language, and as we know java is portable language, so servlet is also portable.
Efficient: Servlets invocation is highly skilled as compared to any CGI programs.
Robust: JVM manages Servlet. That’s why Servlet is robust.
Performance: Servlet creates a thread for each request, so the performance of servlet is better than CGI.
Secure: Because it uses java language, so servlet is safe.

How Servlet Works?

Whenever a request comes, it received by the servlet, and then they forward the request to the web container. A Web container is responsible for handling the request by creating the new thread. Container creates multiple threads to execute various requests.

How Java Servlet Works?


Let’s understand the working of Servlet –
1. The User sends a request by clicking a link for a servlet.
2. Then, the container finds the servlet and Create two instances.
  a.HttpServletRequest
  b.HttpServletResponse
3. After this, the container creates a thread for executing the request. So they call the servlet’s service() method and passes the instances as arguments.
4.Based on the HTTPRequest method sent by client, service( ) method decides which servlet method, doGet() or doPost() to call. 
5. Then, to respond to the client, servlet uses response instance to write the response.
6.After the service( ) method is completed, container call the destroy( ) method. And the request and response instance are prepared for garbage collection.

Servlet API

there are 2 packages of java servlet API are as follow:

1.javax.servlet

This package contains several classes and interfaces that describe and define bonds between a class and environment for an object.

Interface: -

ServletResponse
ServletRequest
RequestDispatcher
ServletConfig
Servlet

Class: -

GenericServlet
ServletRequestWrapper
ServletResponseWrapper
ServletInputStream
ServletOutputStream

Exception

ServletException
UnavailableException

2.javax.servlet.http

This package contains several classes and interfaces that describe and define bonds between a servlet class running under HTTP protocol and environment for an object.

Interface:- 

HttpServletRequest
HttpServletResponse
HttpSession
HttpSessionContext
HttpSessionListener

Class: -

Cookie
HttpServlet
HttpServletRequestWrapper
HttpServletResponseWrapper
HttpSessionEvent




Comments

Post a Comment

Thanks for Reach us !

Popular posts from this blog

A Beginners Guide to Java JDBC

Introduction to JDBC in Java Java Database Connectivity is a standard Java API used to connect Java application with Database. Java JDBC is used to communicate with the different type of Databases like Oracle, MS Access, My SQL and SQL Server. JDBC can also define as the platform-independent interface between a relational database and Java programming. It allows a java program to execute the SQL statement and retrieve the result from the database. JDBC uses drivers to connect with database.  Different Types of JDBC Driver in Java  There are four types of JDBC Drivers:
1. JDBC-ODBC Bridge Driver 2. Natïve Driver 3. Network Protocol Driver 4. Thin Driver Why should we use JDBC? There is some critical point which explains why we should use JDBC.
1. JDBC API is Standard API. We can communicate with any Database without revising our Application, i.e. it is Database Independent API. 2.JDBC Drivers developed in Java, and hence JDBC Concept is applicable for any Platform. i.e., JDBC is Platfor…

10 Difference between C++ and C# Programming Language

What is the Difference Between C++ and C#?

The 10 main Difference between C++ and C# are as follow:

No. C++ C#
1. C++ is a low-level language. C# is a High-level Language.
2. It supports the multiple inheritances. It does not support multiple inheritances.
3. In C++, you require to manage memory manually. C# automatically manages Memory.
4. In C++, after compiling code changed into machine code. In C#, after compiling code is changed into an intermediate language code.
5.

How to do SEO For E-Commerce Website?

A Beginners Guides to Optimization of an E-Commerce website SEO: Search Engine Optimization
Search Engine Optimization, every websites backbone, is the tool that can make or break any website. Optimization of an e-commerce website is more critical and complicated than doing SEO for any other website. It is because your e-commerce site can have many more hundreds or even thousands of product listings that require you to follow best practices ensuring the performance of your website at an optimum level.
Strategy Forgetting to the top of Google search results there should be little margin or room for errors while conducting SEO for your e-commerce website. It is because ideally, you must be looking to be within top three positions to tremendously increase the traffic for your website. The number one ranked result receives the search of 31.24 clicks. The number two gets half of it around 14.04 clicks and so on coming down for rest three ranked searches. These statistics show the importan…

A Beginners Guide to Apache Ant Tutorial Step by Step

Introduction to Apache Ant Tutorial

Ant stands for "Another Neat Tool". It is a general purpose build tool. This build tool is based on java from Apache Software Foundation. Apache Ant's build files are written in XML and they take benefit of being an open standard, portable and easy to learn.

What is Apache Ant?Ant was the first build tool, the reason to build this tool is that created for building Java applications. It is used for building and deploying Java projects but can be used for every feasible repeated task, e.g. generating documentation.
Ant is a cross-platformed and open source project which provides source code, blueprints, and documentation freely available to all the developers. And it provides the facility to users to extend the project by creating their own “antlibs”. Immediately, it became popular as a build tool between Java developers. Ant was created because of a number of problems with Unix's and it was a good replacement for the "Make" b…