Thursday, 21 June 2012

java Servlets interview questions

What is Servlets and explain the advantages of Servlet life cycle?

Servlets are modules that run within the server and receive and respond to the requests made by the client. Servlets retrieve most of the parameters using the input stream and send their responses using an output stream............
Read answer
Explain life cycle of Servlet.

Servlets life cycle involve three important methods, i.e. init, service and destroy.
Init() : Init method is called when Servlet first loaded in to the web server memory............
Read answer
What are different Authentication options available in Servlets.

There are four ways of Authentication options available in servlets
HTTP basic authentication: In this, server uses the username and password provided by the client and these credentials are transmitted using simple base64 encoding..........
Read answer
Explain why HttpServlet is declared abstract.

The Constructor HttpServlet() does nothing because this is an abstract class. Default implementations in a few Java classes like HttpServlet don’t really do anything. Hence, they need to be overridden.............
Read answer
Is possible to have a constructor for a servlet?

Yes, it is possible to have a constructor for a servlet. However, it is not practiced usually. The operations with the constructor can be performed as usual just that it cannot be called explicitly using the ‘new’ keyword.............
Read answer
What is the difference between an Applet and a Servlet?

Applets are applications designed to be transmitted over the network and executed by Java compatible web browsers.
An Applet is a client side java program that runs within a Web browser on the client machine.............
Read answer
Define HTTP Tunneling?

In some organizations, the intranet is blocked by a firewall to the internet. It is exposed to the outer networks only by means of webserver port that accept only Http requests...........
Read answer
List out the difference between ServletConfig and ServletContext?

Both are interfaces in the package javax.servlet. ServletConfig is a servlet configuration object. It is used by a servlet container to pass information to a servlet during initialization. The ServletConfig parameters are specified for a particular servlet and are unknown to other servlets................
Read answer
What is the difference between doGet() and doPost()?

doGet() and doPost() are HTTP requests handled by servlet classes.
In doGet(), the parameters are appended to the URL and sent along with header information. This does not happen in case of doPost(). In doPost(), the parameters are sent separately..............
Read answer
What is the difference between using getSession(true) and getSession(false) methods?

getSession(true) will check whether a session already exists for the user. If yes, it will return that session object else it will create a new session object and return it...........
Read answer
List out the difference between a JavaBean from a Servlet?

Servlets are Java based analog to CGI programs, implemented by means of a servlet container associated with an HTTP server. Servlets run on the server side..............
Read answer
Explain how servlets differ from RMI. Explain the advantages and disadvantages of each technology.

RMI (Remote Method Invocation) are a means of client server communication. In this, the client invokes a method on the server machine and the server machine process returns the result back to the client. We need to run RMI registry to use RMI
Read answer
Define servlet mapping.

Servlet mapping controls how you access a servlet. It is recommended that you don’t use absolute URLs. Instead usage of relative URLs should be done.
Read answer
Explain javax.servlet.http package.
What is Java Servlet?

A servlet is a java class / a program that is a server side component and runs in web container
Read answer
Explain the life cycle of Servlet, i.e. Instantiation, Initialization, Service, Destroy, Unavailable.

The life cycle is managed by the Servlet container in which the servlet is deployed
Explain the purpose of Servlet interface.

The javax.servlet.HttpServlet / javax.servlet.Servlet is the interface that is to be implemented by all the servlets. The servlet’s code / actions / implementation is done by implementing this interface
Read answer
Explain the underlying method of Servlet interface.

The init() method
The service() method
The destroy() method
The getServletConfig()
The getServletInfo() method
Read answer
What is GenericServlet class?

This class implements Servlet and ServletConfig interfaces. This class can be extended by a servlet. It is a common practice that a servlet class extends protocol-specific,.................
Read answer
What is HTTPServlet class?

The HTTPServlet class provides an abstract class that is to be sub classed which is suitable for a web site. The subclass of HTTPServlet class must override any one of the following methods:....................
Read answer
What is Servlet context?

Servlet context is created by the container and can be viewed as a shared memory resource for all the servlets for a web application
Read answer
Explain session tracking in Java Servlet.

The state of requests for the same user is being maintained by the session of a servlet. Session tracking is a mechanism that is tracked and maintained by such requests by the user.................
Read answer
Describe Servlet collaboration.

Servlet collaboration is all about sharing information among the servlets. Collaborating servlets is to pass the common information that is to be shared directly by one servlet to another through various invocations of the methods.................
Read answer
Describe the basics of Servlets.

Servlets are java classes which run on a web server. The results produced by the servlet are viewed on a remote web server. Servlet is a server side component in web applications. The servlets performs the request / response paradigm using the web container. Servlets is the best alternative for CGI..............
Read answer
What are the important items in javax.servlets. Explain them

Servlets : Defines all the methods that a servlets implements. Servlets receives and responds to a request from the web clients. This interface has the methods that are to initialize a servlets, service a request and removal of a servlets from the server
Describe the main purpose of servlets.

A java enabled server’s functionality can be extended by a servlets. Usually a servlets is used to develop web applications in a web server

No comments:

Post a Comment