thumb|400px|Life of a [[JavaServer Pages|JSP file]]

A Jakarta Servlet, formerly Java Servlet is a Java software component that extends the capabilities of a server. Although servlets can respond to many types of requests, they most commonly implement web containers for hosting web applications on web servers and thus qualify as a server-side servlet web API. Such web servlets are the Java counterpart to other dynamic web content technologies such as PHP and ASP.NET.

Introduction

A Jakarta Servlet is a Java class in Jakarta EE that conforms to the Jakarta Servlet API, a standard for implementing Java classes that respond to requests. Servlets could in principle communicate over any client–server protocol, but they are most often used with HTTP. In principle, any servlets can extend the class; however, realistically speaking, all servlets extend the class. Thus "servlet" is often used as shorthand for "HTTP servlet". Thus, a servlet can be used to add dynamic content to a web server using the Java platform. The generated content is commonly HTML, but may be other data such as XML and more commonly, JSON.

The Jakarta Servlet API has, to some extent, been superseded by two standard Java technologies for web services:

  • the Jakarta RESTful Web Services (JAX-RS 2.0) useful for AJAX, JSON and REST services, and
  • the Jakarta XML Web Services (JAX-WS) useful for SOAP Web Services.

A is an object that receives a request and generates a response based on that request. The basic <code>Servlet</code> package defines Java objects to represent servlet requests and responses, as well as objects to reflect the servlet's configuration parameters and execution environment.

The Servlet API, contained in the Java package hierarchy , defines the expected interactions of the web container and a servlet. About two months after the announcements at the conference, the first public implementation was made available on the JavaSoft website. This was the first alpha of the Java Web Server (JWS; then known by its codename Jeeves) which would eventually be shipped as a product on June 5, 1997.

In his blog on java.net, Sun veteran and GlassFish lead Jim Driscoll details the history of servlet technology. James Gosling first thought of servlets in the early days of Java, but the concept did not become a product until December 1996 when Sun shipped JWS. This was before what is now Jakarta EE was made into a specification.

The Servlet1 specification was created by Pavni Diwanji while she worked at Sun Microsystems, with version 1.0 finalized in June 1997. Starting with version 2.2, the specification was developed under the Java Community Process.

{| class="wikitable"

|+ Servlet API history

! Servlet API version !! Released !! Specification !! Platform !! Important Changes

|-

| Jakarta Servlet 6.1 || March 28, 2024 || 6.1 || Jakarta EE 11 || improve HTTP status code and character encoding support

|-

| Jakarta Servlet 6.0 || May 31, 2022 || 6.0 || Jakarta EE 10 || remove deprecated features and implement requested enhancements

|-

| Jakarta Servlet 5.0 || October 9, 2020 || 5.0 || Jakarta EE 9 || API moved from package to

|-

| Jakarta Servlet 4.0.3 || September 10, 2019 || 4.0 || Jakarta EE 8 || Renamed from "Java" trademark

|-

| Java Servlet 4.0 || September 2017 || JSR 369 || Java EE 8 || HTTP/2

|-

| Java Servlet 3.1 || May 2013 || JSR 340 || Java EE 7 || Non-blocking I/O, HTTP protocol upgrade mechanism (WebSocket)

|-

| Java Servlet 3.0 || December 2009 || JSR 315 || Java EE 6 || Pluggability, Ease of development, Async Servlet, Security, File Uploading

|-

| Java Servlet 2.5 || September 2005 || JSR 154 || Java EE 5 || Requires Java SE 5, supports annotation

|-

| Java Servlet 2.4 || November 2003 || JSR 154 || J2EE 1.4 || web.xml uses XML Schema

|-

| Java Servlet 2.3 || August 2001 || JSR 53 || J2EE 1.3 || Addition of <code>Filter</code>

|-

| Java Servlet 2.2 || August 1999 || JSR 902, JSR 903 || J2EE 1.2 || Becomes part of J2EE, introduced independent web applications in .war files

|-

| Java Servlet 2.1 || November 1998 || 2.1a || Unspecified || First official specification, added <code>RequestDispatcher</code>, <code>ServletContext</code>

|-

| Java Servlet 2.0 || December 1997 || || JDK 1.1 || Part of April 1998 Java Servlet Development Kit 2.0

|-

| Java Servlet 1.0 || December 1996|| || || Part of June 1997 Java Servlet Development Kit (JSDK) 1.0