Servlet is a Java program that sudden spikes in demand for a web container. Web container is equipped for taking care of HTTP requests and responses.. Servlet act as an inter-mediatory interface between HTTP request originate from web browsers and Java applications. Servlet runs as a light-weight thread instead of separate OS process.
So, we can say that Servlet is : API’s , Interface , Used to generate dynamic web pages.
Basics of Servlet :
1. Presentation Tier : User interface is the top most level of the application. The main function of it is to translate tasks and results to something the user can understand.
2. Logic Tier : This layer coordinates the application, processes commands , make logical decisions and evaluations and perform calculations.
3.
Data Tier : Here information is store and
retrieved from a database or file system. The information is then passed back
to the logic tier for processing and then last to the user.
The server has the web container having servlet, which assembles information from the database and created output as HTML. The HTML file is sent to by means of HTTP Response to the client side.
Web server is a program that forward HTTP response, and Servlet is a Java Program that manages classes and objects. How is the reaction created in the HTTP design?
It is finished by the web server at work that simply chips away at HTTP protocol. This is finished utilizing a web container present on the web server.
Servlet
Interface
Servlet interface gives common behaviorto all the servlets. Servlet interface characterizes strategies that all servlets must execute.Servlet interface should be executed for making any servlet (either legitimately or in a roundabout way). It gives 3 life cycle strategies that are utilized to introduce the servlet, to support the solicitations, and to pulverize the servlet and 2 non-life cycle techniques.
Servlet Interface has five methods and these are :
1. public void init(ServletConfig config): This method is called by web Container only once in order to initialized the servlet.
2. Public void service (ServletRequest req, ServletResponse resp) : This method is again called by web container. It is called again and again for each incoming client request , in order to execute the servlet.
3. Public void destroy() : This method is called only once by web container that indicates the servlet is being destroy. The purpose of this method is to clean-up tasks.
4. Public String getServletInfo() : returns information about servlet such as writer, copyright, version etc.
5. public ServletConfig getServletConfig() : returns the object of ServletConfig.
Servlet : Life Cycle of a Servlet(Servlet Life Cycle) :
The web
container manage the life cycle of a servlet. Let's have a look on the life
cycle of the servlet:
- Load Servlet Class.
2 Create instance of Servlet.
3. Initialized by call the Servlet init() method.
4. Execute by call the Servlet Service() method.
5. Call the Servlet destroy() method.
1.
Steps when a web application is Deployed and run in Server(Servlet life cycle in detail) :- When we Deployed a web application in web server, server(container) creating an object of whole web application and this object is called Servlet Context. Servlet Context is an interface, so container creates an object of implementing class of this interface.
- Now when a client send the request from the browser to server, here request is interpreted by server and passes it to the web container. Firstly container check the url of the request and matches from web.xml file i.e. is there any servlet mapped in<url-pattern> with coming url request. Now if the Url found the servlet, Life cycle is started else throws an exception.
2.1 If the <url-pattern> matches then firstly container load the servlet class.
In order to load the servlet class , container uses the concept of dynamic binding and class of Java whose name is class and this class have a static method i.e. ForName().
Class c = Class.forName(“our servlet name”);
2.2 Then container create an object of servlet class at run time in order to instantiate the
servlet class, by using newInstance() method of class and typecast it in servlet type.
Servlet s= (Servlet)c.newInstance();
2.3 Then container creates a new object of servlet called ServletConfig object. ServletConfig is an Interface, so container creates an object of implementing.
2.4 Then container call the init method() in
order to initialized the servlet and passes the ServletConfig object in the init method().
Public void init(ServletConfig con);
2.5 The container create a seprate thread and at this separation , thread again creates two object called ServletRequest and ServletResponse .
2.7 Then container creates a dynamic web page and provides the response to the client .After
successfully response to client , container destroy the created thread.
2.8 If the client again send a request, the process again started from step 2.2 to 2.5.
This is all about Servlet!!! Hope it will help you understanding the basics of servlets :)
Now let us jump on the FAQ's from our webniar last week-
Collaboration FAQ's:- **Cisco-CUBE**
All In light of the current COVID-19 situation, a very common question is coming up with regards to CUBE licensing enforcement on session count.
As long as the platform is registered with CSSM for CUBE and platform technology (UCK9, SecK9, etc) licenses in the release where it is required, CUBE session count is NOT enforcedand consuming more sessions on the platform than what the customer's virtual account is entitled for will NOT block calls
Prior to IOS-XE 17.2.1 (which has not yet FCS'ed - target date March 20th, 2020), session consumption reporting is based on mode border element license capacity XXnumber and again in this case, if XX is greater than customer's entitlement, CSSM will not report out of compliance and no calls will be blocked.
From 17.2.1 onwards, session count is dynamically calculated and reported to CSSM and this CLI (mode border element) is not used, and again, exceeding the session count does not block calls.
That's all for today's blog , stay tuned and subscribe for more updates!!! Cheers :)