Features of Java Servlet
There are 5 Features of Servlet are as Follow:
Portable: Servlet uses Java Programming language, and as we know java is portable language, so servlet is also portable.
Efficient: Servlets invocation is highly skilled as compared to any CGI programs.
Robust: JVM manages Servlet. That’s why Servlet is robust.
Performance: Servlet creates a thread for each request, so the performance of servlet is better than CGI.
Secure: Because it uses java language, so servlet is safe.
How Servlet Works?
Whenever a request comes, it received by the servlet, and then they forward the request to the web container. A Web container is responsible for handling the request by creating the new thread. Container creates multiple threads to execute various requests.
Let’s understand the working of Servlet –
1. The User sends a request by clicking a link for a servlet.
2. Then, the container finds the servlet and Create two instances.
a.HttpServletRequest
b.HttpServletResponse
3. After this, the container creates a thread for executing the request. So they call the servlet’s service() method and passes the instances as arguments.
4.Based on the HTTPRequest method sent by client, service( ) method decides which servlet method, doGet() or doPost() to call.
5. Then, to respond to the client, servlet uses response instance to write the response.
6.After the service( ) method is completed, container call the destroy( ) method. And the request and response instance are prepared for garbage collection.
Servlet API
there are 2 packages of java servlet API are as follow:
1.javax.servlet
This package contains several classes and interfaces that describe and define bonds between a class and environment for an object.
Interface: -
ServletResponse
ServletRequest
RequestDispatcher
ServletConfig
Servlet
Class: -
GenericServlet
ServletRequestWrapper
ServletResponseWrapper
ServletInputStream
ServletOutputStream
Exception
ServletException
UnavailableException
2.javax.servlet.http
This package contains several classes and interfaces that describe and define bonds between a servlet class running under HTTP protocol and environment for an object.
Interface:-
HttpServletRequest
HttpServletResponse
HttpSession
HttpSessionContext
HttpSessionListener
Class: -
Cookie
HttpServlet
HttpServletRequestWrapper
HttpServletResponseWrapper
HttpSessionEvent
Thank you very much for shared this. I got lot of ideas after reading this. Share more as similar to this.
ReplyDeletecore java training in chennai
core java training institutes in chennai
core java Training in Velachery
C C++ Training in Chennai
javascript training in chennai
Appium Training in Chennai
JMeter Training in Chennai
core java training in chennai
Hi there, I enjoy reading through your article.
ReplyDeleteI like to write a little comment to support you. share some more info.
Ai & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
Its truly helpful..if you could likewise post ans that would have been incredible. good work
ReplyDeleteAi & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
I was following your blog regularly and this one is very interesting and knowledge attaining. Great effort ahead. you can also reach us for
ReplyDeleteweb design company in chennai
web development company in chennai
website designers in chennai
website designing company in chennai
web design in chennai
website development company in chennai