Sunday, January 27, 2013

Servlets Interview Questions -1


                                           Servlets Interview Questions -1

1. What is the difference between CGI and Servlet?

Advantages of servlets over CGI are:-
· Servlets are multithreaded which can support multiple users’ requests. i.e., servlet is a
resource and where as requests are treated as threads. So multiple requests (threads) can
access a single instance of servlet resource asynchronously. Whereas CGI provide a new
instance for every request, it is a single thread model .By creating new instance every
request server won’t support multiple requests.
· Servlets are used to generate dynamic content.
· Servlets are platform independent.
· Servlets are more efficient compare to other server side programming.

2. What is meant by a servlet?

Servlet is a server side component written in java, which can host request of client,
process the request and response sent back to the client.
Servlet is a java program that is run inside a servlet engine called web server. It take
requests from client and responds to those requests.

3. What are the types of servlets? What is the difference between 2 types of Servlets?

There are two types of servlets provided by servlet API those are
1) GenericServlet- It can use for any type of protocols (http, ftp, telnet)
It is protocol independent ,it support service() method only
2) HttpServlet- It can use for only http protocol, it support doGet() and doPost() methods
with Service() methods

4. What is the type of method for sending request from HTTP server?

Http server request can sent in two types one is GET and second one is POST

5. What are the exceptions thrown by Servlets? Why?

Exceptions thrown by servlet are:
ServletException
IOException

No comments:

Post a Comment

Thank you share the knowledge U have with in U.