What is Servlets and explain the advantages of Servlet life cycle?- Servlets are modules that run within the server and receive and respond to the requests made by the client.
- Servlets retrieve most of the parameters using the input stream and send their responses using an output stream.
- Servlets are used to extend the server side functionality of a website.
- They communicate with various application on the server side and respond to the request made by the client.
What are the general advantages and selling points of servlets?Servlets exhibit the following characteristics:
- Can handle multiple requests concurrently.
- Can synchronize requests.
- Can forward requests to other servers and servlets.
- Portable (Servlets are written in the java programming language and follow a standard API).
- They are secure (Like CGI, they don’t run shell and memory overflow, etc is handled by Java).
- Inexpensive (There are a number of free or very inexpensive web servers that are good for development use or deployment of low- or medium-volume Web sites).
What are the advantages using servlets over using CGI?- CGI programs run outside the webserver.
- So a new process must be started to execute a CGI program.
- CGI programs are designed to handle a single request at a time. After that they return the result to the web server and exit.
- On the other hand servlets can handle multiple requests concurrently.
- They run within web servers.
- They generate dynamic content that is easier to write and faster to run.