Servlet – Online Tutorial Skip to content Online Tutorial Menu Close Home Open menu JDBC JPA tutorial jQuery tutorial jQuery UI Tutorial JSF JSON Jsoup JSP Julia Tutorial JUnit Log4j MariaDB tutorial Marketing Tutorial Math tutorial Open menu MongoDB Tutorial MS Word Tutorial MySQL tutorial Oracle tutorial PHP Physics Tutorial PL/SQL Post Article PostgreSQL tutorial PouchDB tutorial PowerPoint tutorial Python tutorial Open menu Quartz Scheduler Question Sidebar ReactJS tutorial Scala Tutorial Servlet Shell/Bash Tutorial Spring SQL SQLite tutorial Struts2 TypeScript tutorial Open menu Typography Users WAR Android Tutorial Angular 7 Tutorial Angular 8 Tutorial AngularJS Ant Apache maven tutorial Backbone.js tutorial Open menu Biology tutorial Bootstrap Bootstrap 4 C tutorial for beginners C-Sharp Tutorial Cassandra tutorial Chemistry tutorial Cloud Computing Tutorial Computer fundamentals tutorial CouchDB tutorial CPP tutorial CSS tutorial DBMS Tutorial DTD Tutorial English Grammar Tutorial Open menu Excel Tutorial Full Form Generics Hibernate Hindi Tutorial HR tutorial HTML tutorial iText JAR Java Mail Java Tutorial Javascript JAXB Web services WordPress Tutorial XML DOM Tutorial Open menu XML Parser XML Tutorial XPath Tutorial XQuery Tutorial XSD (XML Schema Definition) Tutorial XSLT Tutorial Web Stories – W3schools Q&A Open menu CPP Q&A C# Q&A C Q&A World Servlet Eclipse Java servlet API tutorial for beginners and professionals with examples on Basics, Life Cycle, Servlet Examples, Client Request, Server Response, Deployment Descriptor, Request Dispatcher, Http Codes, Servlet Filters, Cookies, Sessions and more. Web application: A web application or website is an application program which accessed over a network connection using HTTP and often runs inside a web browser. Web browser: A web browser is a program which acts as an interface between user and web application e.g. Internet Explorer, Chrome, Safari, Mozilla firefox etc. CGI (Common gateway interface): CGI was the first protocol or way of communication between web server and program. It passes a request from a web user to an application program and receives data back to forward to the web user i.e. It is responsible for dynamic content generation. Advantages of CGI: Technology portability: CGI programming can be written in variety of languages like c, c++, perl. Web server portability: All service providers support CGI Programs. Disadvantages: Response time is high. CGI scripts are platform-dependent. For every request, a new process will be started and web server is limited to start processes. CGI programs are not object oriented always. Servlet overcomes the above disadvantages. Servlet as technology: As a technology servlet provides a model of communication between a web user request and the application or program on the web server. Servlet as component: As a component servlet is a program which is executed in web server and responsible for dynamic content generation. Main tasks of servlet: Read the implicit and explicit data sent by web browser. Generate result by processing the data. Send the implicit and explicit data as a response to the web browser. Servlet Packages: javax.servlet and javax.servlet.http packages contains the classes and interfaces for servlet API. These packages are the standard part of Java’s enterprise edition. javax.servlet contains a number of classes and interfaces which are mainly used by servlet container. javax.servlet.http contains a number of classes and interfaces which are mainly used by http protocol. Differences between CGI and Servlet. CGI Servlet CGI is process based. For every request a new process will be started. Concurrency problems can’t occur in CGI because it is process based. Platform dependent. Can be written in variety of languages like c, c++, perl. Response time is high. Servlet is thread based. For every request a new thread will be started. Concurrency problems can occur in servlet because it is thread based. Platform independent. Can be written only in java. Response time is low. Java Servlet tutorial: Life cycle of a servlet Servlet interface in java with example GenericServlet class in java with example HttpServlet class in java with example Deployment Descriptor: web.xml file with example welcome-file-list in web.xml with example load-on-startup in web.xml with example RequestDispatcher interface with example sendRedirect in servlet with example Servlet Init parameters and ServletConfig interface with example Servlet context parameters and ServletContext interface with example Servlet Hello World Example using annotation with example Session management and cookies in servlet with example Cookie in servlet with example Hidden field in servlet with example URL rewriting in servlet with example HttpSession in servlet with example Servlet filter in java with example FilterConfig interface with example All java servlet example in eclipse Maven Eclipse Servlet Maven Eclipse Servlet Servlet interview questions Servlets Interview Questions and Answers Online Tutorial Proudly powered by WordPress.