Servlets Interview Questions

Servlets  Interview Questions
1) Explain in detail about a servlet?
A Java servlet can be thought as an Applet but this runs on the server without the front side. This is used in applications where there is need for functionality of the web server and it is also used to access the existing business applications. It removes the limitations caused due to CGI. Servlet is platform and server independent which makes it much more popular to use.
2) State some of the uses of Java servlet?
Java servlet is used for many purposes. Being platform and server independent it is used for wide variety of purposes. They can provide secured access to web based data. Type safety and RAD based features help in productivity. It can be used to extend the functionality present in web servers.
3) What services can be obtained by implementing Java Servlets?
These are the following services which can be obtained by using Java servlets they are: -
• Multi user services can be provided by organization using Java servlets to their clients.
• They can also serve static web pages by making use of HTTP/ (s) protocols.
• Search engines and semi custom applications can make use of servlets (web based entry, etc).
4) Should the user or client be in the same software language in their applications?
Servlets are programmed in Java and the user need not be in the same language to access or implement the features of Servlets. They are used in middle tier which provides them a flexibility to be clients for other applications and the client who is accessing the servlet need not have the same language as the servlet.
5) Is load balancing possible with a servlet?
Load balancing is possible with the use of servlets. A servlet can forward requests to other servers which can drastically reduce load. This technique can reduce load by mirroring the same content among several servers. A single logical service can be partitioned among several servers i.e., routing according to task type.
6) Explain about the service method?
Request and Response parameters are provided with the service methods. These parameters implement encapsulation; they also give access to parameters which allows them to report errors and status reports. Contrarily servlets retrieve parameters through an input stream and responses are sent through output stream.
7) Explain about the different usage modes present in Java servlet?
Servlets can be used in many different modes they are: -
1) Filter chains can be used to chain servlets together.
2) They can be used to support HTTP protocols.
3) They are the best replacement for CGI based applications
4) Dynamic generation of content is possible with Servlets.
8) State the different ways of loading a servlet?
The different ways in which a servlet can be loaded are as follows: -
1) Dynamic loading of servlet is always possible.
2) Servers do provide an administrative option through which force loading and initialization is possible.
3) Servlets can also be loaded by Java class; they can be loaded from remote directories and local file systems.
9) Explain about servlet container?
Servlet container supports servlet execution. Basic functionality of a web server and IDE of Java can be used for better performance. Specific URL`s can be translated into servlet requests. Individual servlets get them selves registered with the container and this container holds and provides information about the functionality of the servlet and the Url which can access the servlet.
10) Explain about servletConfig and servletContext in applications?
Servletcontext is used to obtain application level information and only one servletcontext can be present in one application. ServletConfig object is present for every servlet and it provides initialization parameters for every servlet.
11) Explain about Http specific servlets?
Servlets using Http protocol support Http methods which includes GET, HEAD, POST, etc. Request and response data are always provided in an MIME format. Data type is specified by the servlet and data is also written in that format which gives greater flexibility in sending output in the format requested.
12) Explain about performance features of servlets?
Creation of a new process for each and every request can be avoided and this is deemed to be the biggest performance feature of servlets. Servlets run in parallel and in hand with the same process in the server. It provides greater flexibility and performance over CGI and fast CGI in an HTTP environment.
13) Explain about JVM and Java servlets?
Java servlets give greater performance for leveraging Java and related internet technologies. Throughput and response time can be improved by using Java servlets. With help from JVM Java servlet programs take advantage of additional processors which will help them scale up operations from entry level servers to main frame level applications.
14) How does servlets handle data and give some examples of this feature?
Servlets with precoded logic process data and they return reports in an appropriate format. Some of the examples of such formats are historical graphs and tables, web data, automated forecasts, etc. Administrative data such as addition, deletion of data can be performed with Servlets.
15) What are the two different kinds of servlets used by collecting sites?
There are two kinds of servlets used by collecting sites they are used to push and pull data. One kind of servlet is used to push data to the collecting site and the other is used to pull data from the appropriate format. These formats can be clubbed with other servlets which further aggregate data and can be used for large engineering projects.
16) What are the various different input parameters which servlets accept?
There are various different iinput parameters which servlets accept they are
1) Request or an input stream from an applet or so.
2) Request of the URL
3) From different servlets or networks.
4) Parameters passed from an HTML form.
17) Explain about the security features of Servlets?
Servlets cannot be trusted they have information about the clients. They have access to HTTP specific authentication data and peer identities can be determined. Strong security policy support is present in Java servlets. Access to network files and services needs to be restricted for a servlet. Security manager provided by Java can be used to control the level of security.

No comments: