**7. Remote evaluation**

In computer science, remote evaluation is a term that belongs to the family of mobile code, within the field of code mobility. It is for any technology that involves the transmission of executable software code from a client hosts to a server hosts for execution to be happen at the server and the result is sent back to the client after execution for this resources of server sside are used [19]. A simple model of remote evaluation is illustrated in **Figure 13**.

An example for remote evaluation is grid computing: An executable task may be sent to a specific computer in the grid. After the execution has terminated, the result is sent back to the client. The client in turn may have to reassemble the different results of multiple concurrently calculated subtasks into one single result.

whether an instance of the requested servlet exists. If the servlet instance exists then the Web container delegates the request to the servlet, which process the client request and sends back

Evolution and Paradigm Shift in Distributed System Architecture

http://dx.doi.org/10.5772/intechopen.80644

19

It is the job of Web container to get the request and response to the servlet. The container creates multiple threads to process multiple requests to a single servlet. So in case the servlet instance does not exist, the Web container locates and loads the servlet class. The Web container then creates an instance of the servlet and initializes it. The servlet instance starts processing the request after initialization. The Web container passes the response generated

Servlets don't have a main() method that's why Web container manages the life cycle of a Servlet instance. The life cycle of the servlet includes three states: new, ready and end. The servlet is in new state if servlet instance is created. After invoking the init() method, Servlet comes in the ready state [21]. In the ready state, servlet performs all the tasks. When the web container invokes the destroy() method, it shifts to the end state. It is shown

**a.** Servlet class is loaded: The class loader is responsible to load the servlet class. The servlet class is loaded when the first request for the servlet is received by the web container. **b.** Servlet instance is created: The web container creates the instance of a servlet after loading the servlet class. The servlet instance is created only once in the servlet life cycle.

**c.** Init method is invoke: The web container calls the init method only once after creating the

**d.** Service method is invoked: The web container calls the service method each time when request for the servlet is received [22]. If servlet is not initialized, it follows the above three steps then calls the service method. The servlet is initialized only once so if servlet is

Method Signature: public void service(ServletRequest request, ServletResponse response)

Method Signature: public void init(ServletConfig config) throws ServletException

servlet instance. The init method is used to initialize the servlet.

already initialized, it directly calls the service method.

throws ServletException, IOException.

the response (Shown in **Figure 15**).

**Figure 14.** Architecture of servlets.

by the servlet to the client.

in **Figure 16**.

*7.1.3. Life cycle of servlet*
