What is Servlet? Explain the position of servlets in web applications with suitable diagram.
Java servlets are server-side program that runs inside a web server and handle client requests and return a dynamic response for each request. The dynamic response could be based on the user's input (e.g., search, online shopping, online transaction) with data retrieved from databases or other applications, or time-sensitive data (such as news and stock prices). It acts as a middle layer between requests coming from a Web browser or other HTTP client and databases or applications on the HTTP server (The web server).
The following diagram shows the position of Servlets in a Web Application.
Servlets perform the following major tasks
Read the explicit data sent by the clients: This includes an HTML form on a Web page or it could also come from an applet.
Read the implicit HTTP request data sent by the clients: This includes cookies, media types and compression schemes the browser understands, and so forth.
Process the data and generate the results: This process may require talking to a database, invoking a Web service, or computing the response directly.
Send the explicit data to the clients: This document can be sent in a variety of formats, including text (HTML or XML), binary (GIF images), Excel, etc.
Send the implicit HTTP response to the clients: This includes telling the browsers or other clients what type of document is being returned (e.g., HTML), setting cookies and caching parameters, and other such tasks.
Comments
Post a Comment