IGNOU BCA MCA Students - VIVA Question Answer for JAVA Servlet
JAVA Servlet Selected Question Answer - PART XI
91. What is a Servlet ? The servlet is a Java
programming language class used to process client requests and generate dynamic
web content. Servlets are mostly used to process or store data submitted by an
HTML form, provide dynamic content and manage state information that does not
exist in the stateless HTTP protocol.
92. Explain the architechure of a Servlet. The core
abstraction that must be implemented by all servlets is the
javax.servlet.Servlet interface. Each servlet must implement it either directly
or indirectly, either by extending javax.servlet.GenericServlet or
javax.servlet.http.HTTPServlet. Finally, each servlet is able to serve multiple
requests in parallel using multithreading.
93. What is the difference between an Applet and a Servlet ? An Applet is a
client side java program that runs within a Web browser on the client machine.
On the other hand, a servlet is a server side component that runs on the web
server.An applet can use the user interface classes, while a servlet does not
have a user interface. Instead, a servlet waits for client’s HTTP requests and
generates a response in every request.
94. What is the difference between GenericServlet and
HttpServlet ? GenericServlet is a generalized and protocol-independent
servlet that implements the Servlet and ServletConfig interfaces. Those
servlets extending the GenericServlet class shall override the service method.
Finally, in order to develop an HTTP servlet for use on the Web that serves
requests using the HTTP protocol, your servlet must extend the HttpServlet
instead. Check Servlet examples here.
95. Explain the life cycle of a Servlet. On every
client’s request, the Servlet Engine loads the servlets and invokes its init
methods, in order for the servlet to be initialized. Then, the Servlet object
handles all subsequent requests coming from that client, by invoking the
service method for each request separately. Finally, the servlet is removed by
calling the server’s destroy method.
96. What is the difference between doGet() and doPost() ? doGET: The GET method appends the name-value pairs on the request’s
URL. Thus, there is a limit on the number of characters and subsequently on the
number of values that can be used in a client’s request. Furthermore, the
values of the request are made visible and thus, sensitive information must not
be passed in that way. doPOST: The POST method
overcomes the limit imposed by the GET request, by sending the values of the
request inside its body. Also, there is no limitations on the number of values
to be sent across. Finally, the sensitive information passed through a POST
request is not visible to an external client.
97. What is meant by a Web Application ? A Web
application is a dynamic extension of a Web or application server. There are
two types of web applications: presentation-oriented and service-oriented. A
presentation-oriented Web application generates interactive web pages, which
contain various types of markup language and dynamic content in response to
requests. On the other hand, a service-oriented web application implements the
endpoint of a web service. In general, a Web application can be seen as a
collection of servlets installed under a specific subset of the server’s URL
namespace.
98. What is a Server Side Include (SSI) ? Server Side Includes
(SSI) is a simple interpreted server-side scripting language, used almost
exclusively for the Web, and is embedded with a servlet tag. The most frequent
use of SSI is to include the contents of one or more files into a Web page on a
Web server. When a Web page is accessed by a browser, the Web server replaces
the servlet tag in that Web page with the hyper text generated by the
corresponding servlet.
99. What is Servlet Chaining ? Servlet Chaining is the method where the
output of one servlet is sent to a second servlet. The output of the second
servlet can be sent to a third servlet, and so on. The last servlet in the
chain is responsible for sending the response to the client.
100. How do you find out
what client machine is making a request to your servlet ? The ServletRequest
class has functions for finding out the IP address or host name of the client
machine. getRemoteAddr() gets the IP address of the client machine and
getRemoteHost() gets the host name of the client machine.
No comments:
Post a Comment