Let's learn java programming language with easy steps. This Java tutorial provides you complete knowledge about java technology.

Tuesday 15 August 2017

What is Servlet In Java


Java Servlet

Here we will cover in detail what is servlet in java and why we used java servlet and what is the features of the servlet. So let's start

Java servlet is a technology which is used to create a web application. Web application means a collection of web pages e.g websites.

Servlet is server side programming or java program which is executed in JVM on the web server, In other words, it executes on the web server.

Servlet technology is used to create dynamic web pages. Dynamic web pages means, which is not same for all users e.g suppose there are 100 students and they want to see their marks online. Every student will get different-different marks according to their filling enrollment numbers on dynamic web pages.

There are two types of pages :

Dynamic Web Page: Which is not same for all users.

Static Web Page: Which is same for all users.

You can define servlet in many ways and these are :

  • Servlet is a JEE technology.
  • Servlet is a technology which is used to create a web application.
  • Servlet is an API in java i.e java servlet API provides some classes and interfaces for generating dynamic web pages or create a web application.
  • Servlet is an interface, if you want to create servlet then you have to implement this servlet interface.
  • Servlet is a class that extends the capabilities of servers and respond to the incoming request.

          
                                                   

                                                                                
There are some other technologies which is used to create a web application and make dynamic web pages e.g JSP(Java Server Page) but there is some difference between Servlet and JSP. We will learn in later, what is jsp in java and what is jsp life cycle etc.


Common Gateway Interface - CGI

Common gateway interface is a specification for transferring information between a world wide web server and CGI programs. A CGI program is any program designed to accept and return data that conforms to the CGI specification.


The program could be written in any programming language including perl, java, c, or visual basic.

Common gateway interface programs are the most common way to interact dynamically with the user.


Disadvantages of CGI

  • For each request, it starts a process and the web server is limited to start processes.
  • Common gateway interface uses platform dependent language e.g c, c++, etc.

Advantages of Servlet Over CGI

  • For handling multiple requests the web container creates the threads and we know very well that thread is light weight, share common memory areas whereas process is heavy weight and take separate memory area.

Features of Servlet

Servlet in java has many features e.g
  • Good Performance: Good performance of servlet is it creates a thread for handling each request not process(like CGI).
  • Portability: It has great portability because it uses java programming language and java is a robust language.
  • Secure : It uses java and java is a secure language.
  • Using oops: Servlet can take advantage of the object oriented programming Because servlet uses java .

I hope this introduction to java servlets will help you. In next java servlet tutorials, we will learn what is servlet life cycle and servlet methods etc. 
Share:

0 comments:

Post a Comment

Facebook Page Likes

Follow javatutorial95 on twitter

Popular Posts

Translate