Servlets
Servlets
What is Servlet?
Servlets are nothing but the Java programs which reside on the
server side and their main purpose is to serve the client request. Servlets are
used to develop dynamic web applications and they are platform
independent, robust, and secured.
1. Better performance:
Because it creates a thread for each request, not
process.
2. Portability:
Because it uses Java language.
3. Robust:
JVM manages Servlets, so we don't need to worry
about the memory leak, garbage collection, etc.
4. Secure:
Because it uses java language.
Life Cycle of a Servlet (Servlet Life Cycle)
The web container maintains the life cycle of a servlet instance.
Let's see the life cycle of the servlet.
We must have come across many situations when you need to pass
some information from your browser to web server and ultimately to your
backend program.
Never use the GET method if you have password or other sensitive
information to pass to the server. The GET method has size limitation: only
1024 characters can be used in a request string.
The data submitted with POST method type is sent in the message
body so it is secure and cannot be seen in the URL. And there is no limit
on the data that can be sent through the POST method.
This method should be used on the parameter that has only one
value. If multiple values are there, then it returns only the first value.