Servlet

Servlet technology mainly used for web application creation at server side and dynamic web pages. Before Servlets, CGI (Common Gateway Interface) scripting language was used as a server-side programming language. But, there were many disadvantages of this technology.

Disadvantages of CGI:

  • If number of clients will send requests, it takes more time for sending response.
  • For each request, it starts a process and web server is limited to start process.
  • It uses platform dependent language. e.g: C,C++,etc.
Advantages of Servlet:
  • Better performance it creates new thread for each request.
  • Portability because it uses java language.
  • Robust Servlets are managed by JVM. So, no need to worry about memory leak, garbage collection and etc.
  • Secure because it uses java language.
How to create dynamic web project in eclipse?
Follow the below instructions to create the Dynamic web project in eclipse. 

      File ---> new ---> Dynamic web project

  • Please fill the Project Name field as shown in below screenshot. You can define your own Project Name. 
  • Choose Target Runtime as per your convenience, if any web servers has been installed. 
  • Dynamic Web Module Version will be identified based on the configured Target Runtime server.
  Click on 'Next' to move forward in web project creation.
click on 'Finish' button to create Dynamic web project. Your New project has been listed in project list.

We have to add servlet-api.jar to load all the servlet class files into newly created web application. To download "servlet-spi.jar" and add the JAR file into Dynamic web project class path. 

If you're using maven project, just you can add dependency in your pom.xml file as followed below,

<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api-2.5</artifactId>
<version>6.1H.14</version>
</dependency>

Comments

Popular posts from this blog

Hibernate auto increment with example

how to count the page views by using JSP

Multithreading in java with example

How to retrieve data from table by using JDBC with example

Prime, Fibonacci and Factorial number with example in java

How to insert images into database using JDBC?

How to sort list of objects in java with examples

String interview questions and answers

Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/SystemException

Store file into table by using JDBC with example