Servlets - SPLessons

Introduction to Servlets

Home > Lesson > Chapter 2
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Introduction to Servlets

Introduction to Servlets

shape Description

Introduction to Servlets, The Servlet is a Java program which can run in Web server or Application server and act as a mediator from a web browser or client to the database or Server. For this Servlet, one can take input from the users through HTML or Web forms and can also take present records from databases and create web forms dynamically. Now, there comes a doubt about what is a Web server and Application server. Web server only supports Web application like Servlets, JSP, HTML and Application Server support Enterprise Edition like Servlets , JSP , HTML, EJB (Enterprise Java Bean) , JMS (Java Message Service) and the Application Server is Superior (Web Server + EJB + JMS).

shape Conceptual figure

Following is a conceptual figure which gives more information regarding web server and application server. A Web server handles the HTTP convention. At the point when the Web server gets a HTTP request, it reacts with a HTTP reaction, for example, sending back a HTML page. To prepare a solicitation, a Web server may react with a static HTML page or picture, send a redirect, or delegate the dynamic reaction era to some other program, for example, JSPs (JavaServer Pages), servlets, server-side JavaScripts. An application server opens business logic to browser applications through various protocols, potentially including HTTP. While a Web server chiefly manages sending HTML for expose in a Web program, an application server gives access to business logic to utilize by browser application programs.

shape Packages

Following are the packages of Servlet. While developing an application developer must need to import this packages otherwise errors will be raised automatically and asks to import. javax.servlet.* package contains a number of classes and interfaces that define the agreement between the servlet class and the run-time environment provided an instance of the servlet class by a conforming servlet container. javax.servlet.http.* package  contains a number of classes and interfaces that define the agreement between the servlet class under HTTP protocol and the run-time environment provided an instance of the servlet class by conforming servlet container. Click Here To Know more about Java Packages

Summary

shape Key Points

  • Servlet is similar to APPLETS , but applets are persistent.
  • Servlet creates a thread in which thread takes only HTTP Request and Response is processed.
  • Servlets packages will be used in Java frameworks also while developing web applications.