Java Servlet

Servlet is a Java class which runs on a web server where back end application resides. This is a middle layer between web browser from where HTTP request originate and application web server.

Servlet helps us to get data submit by end users using POST request and return data to web browser using GET request from application web server.

Java web application J2EE helps us to create servlet classes and deploy on web server in the form of war file.

Java Servlet classes related classes belongs to javax.servlet and javax.servlet.http packages to implement servlet program.

HttpServlet

HttpServlet class is an abstract class belongs to javax.servlet.http.HttpServlet package and extends GenericServlet abstract class. We can create servlet using HttpServlet class. HttpServlet methods GET, POST, PUT etc. allows us to handle HTTP requests.

Over all flow / Architecture

Below architecture is all about send data from web browser to servlet program and back from servlet program to web browser.

  • The request will get originate from web browser to get and send data from to server.
  • Request will use HTTP or HTTPS protocol to get or send data to server.
  • The request from web browser will first reach to web server(apache tomcat, JBoss, etc.).
  • Web server will call specific servlet program depending on servlet URL mapping, request type(GET, POST, DELETE etc. ), content type etc.
  • Web browser can send or get data from server in predefined formats such as JSON, XML, binary etc.
  • Servlet class will collect data from web browser. Servlet class will process the data collected from browser. Servlet class will and save/store same data in database. Servlet class can also collect data from database and send back to browser in same predefined format.
  • Servlet class will process data using third party API data and other classes within application server.

Imran Khan

Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.

  • Languages: Java, Python
  • Frameworks: J2EE, Spring, Struts 2.0, Hibernate
  • Web Technologies: React, HTML, CSS
  • Analytics: Adobe Analytics
  • Tools & Technologies: IntelliJ, JIRA

🌐 LinkedIn

📝 Blogs

📧 Imran Khan