
#Keeps defaulting to flowlayout code#
1�Encapsulation : Encapsulation is the mechanism that binds together code and the data it manipulates and keeps both safe from outside interference and misuse.Inheritance: Inheritance is the process by which one object acquires the properties of another object.Polymorphism: Polymorphism is a feature that allows one interface to be used for a general class of actions. The service method supports standard HTTP client requests by dispatching each request to a method designed to handle that request. 9) What is the servlet Lifecycle?ANSWER : Each servlet has the same life cycle: A server loads and initializes the servlet (init())The servlet handles zero or more client requests (service())The server removes the servlet (destroy())(some servers do this step only when they shut down) 10) How HTTP Servlet handles client requests?ANSWER : An HTTP Servlet handles client requests through its service method. Provides an output stream, ServletOutputStream and a Writer through which the servlet can send the reply data. The input stream, ServletInputStream.Servlets use the input stream to get data from clients that use application protocols such as the HTTP POST and PUT methods.8) What information that the ServletResponse interface gives the servlet methods for replying to the client? ANSWER : It Allows the servlet to set the content length and MIME type of the reply. 7) What information that the ServletRequest interface allows the servlet access to?ANSWER : Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by the client, and the names of the remote host that made the request and the server that received it. 6) When a servlet accepts a call from a client, it receives two objects- What are they?ANSWER : ServeltRequest: Which encapsulates the communication from the client to the server.ServletResponse: Whcih encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are interfaces defined by the rvlet package.

Servlet writers provide some or all of these methods when developing a servlet.

Sample Applet 1) Prints "Hello World".2) Generates a runtime error.3) Does nothing.4) Generates a compile time error.Answer : 2What is the effect of compiling and (if possible) running this class:public class Calc 17) The Math.random method is too limited for my needs- How can I generate random numbers more flexibly?ANSWER : The random method in Math class provide quick, convienient access to random numbers, but more power and flexibility use the Random class in the java.util package.double doubleval = Math.random() The Random class provide methods returning float, int, double, and long values.nextFloat() // type float 0.0 Generic Servlet->HttpServlet->MyServlet.The Servlet interface declares, but does not implement, methods that manage the servlet and its communications with clients.
