Servlets Interview Questions And Answers

Servlets Interview Questions list for experienced

  1. What is different between web server and application server?
  2. Which HTTP method is non-idempotent?
  3. What is a Servlet?
  4. Why servlet is mostly used?
  5. What is called servlet container?
  6. What is a filter?
  7. How can we refresh automatically when new data has entered the database?
  8. What is called a session?
  9. What is servlet mapping?
  10. What is a servlet context?
  11. Which interface should be implemented by all servlets?
  12. What is life cycle of Servlet?
  13. What is the difference between Servlet Request and Servlet Context when calling a Request Dispatcher?
  14. What are the features added in Servlet 2.5?
  15. When servlet is loaded?
  16. When Servlet is unloaded?
  17. What are the supporting protocol by HttpServlet ?
  18. What is called Session Tracking?
  19. Why session tracking is needed?
  20. What are the types of Session Tracking ?
  21. What are the advantages of cookies?
  22. What is URL rewriting?
  23. What is servlet lazy loading?
  24. What is Servlet Chaining?
  25. What are the important functions of filters?
  26. What are the functions of Servlet container?
  27. What is the difference between JSP and Servlets ?
  28. What are all the ways for session tracking?
  29. What is called Scriptlet?
  30. What is the difference between Server and Container?
  31. Can we refresh servlet in client and server side automatically?
  32. What is the difference between ServletConfig and ServletContext?
  33. What is Pure Servlet?
  34. What is the difference between Servlets and applets?
  35. What is Generic Servlet class?
  36. What is Java Servlet?
  37. What is String Tokenizer?
  38. What is HttpServlet and how it is different from GenericServlet?
  39. How to get the current HttpSession object?
  40. What do you mean by Default initialization in Java Servlet?
  41. What is Servlet Invoker?
  42. What is called Servlet mapping?
  43. What are all the protocols supported by HttpServlet?
  44. Which exception is thrown if servlet is not initialized properly?
  45. Who is responsible for writing a constructor?
  46. What are all the advantages of Servlet over CGI?
  47. What are the different mode that servlets can be used?
  48. What are the uses of servlets?
  49. Whether we can get deadlock situation in Servlets?
  50. What is the default HTTP method in the servlet?
  51. Whether thread can be used in Servlets?
  52. What exception should be thrown when servlet is not properly initialized?

Servlets interview questions and answers on advance and basic Servlets with example so this page for both freshers and experienced condidate. Fill the form below we will send the all interview questions on Servlets also add your Questions if any you have to ask and for apply in Servlets Tutorials and Training course just send a mail on info@pcds.co.in in detail about your self.

Top Servlets interview questions and answers for freshers and experienced

What is Servlets ?

Answer : Servlets are programs that run on a Web or Application server and act as a middle layer between a request coming from a Web browser or other HTTP client and databases or applications on the HTTP server.

Questions : 1 :: What is different between web server and application server?

A web server responsibility is to handler HTTP requests from client browsers and respond with HTML response. A web server understands HTTP language and runs on HTTP protocol. Apache Web Server is...View answers

Questions : 2 :: Which HTTP method is non-idempotent?

A HTTP method is said to be idempotent if it returns the same result every time. HTTP methods GET, PUT, DELETE, HEAD, and OPTIONS are idempotent method and we should implement our application to make...View answers

Questions : 3 :: What is a Servlet?


A servlet is a Java technology and it is managed by a container called servlet engine. It generates dynamic content and interacts with client through Request and Response.

Questions : 4 :: Why servlet is mostly used?

Servlets are mostly used because they are platform-independent Java classes and are compiled to platform-neutral byte code. Java byte code can be loaded dynamically into and run by java enabled web...View answers

Questions : 5 :: What is called servlet container?

A servlet container is a part of Web server that provides network services depends on request and response are sent, MIME based requests and responses. It contains and manages servlets through their...View answers

Questions : 6 :: What is a filter?


A filter is nothing but a piece of code which can be reusable that will be transforming the content of HTTP requests, response and header information.

Questions : 7 :: How can we refresh automatically when new data has entered the database?

Refresh in Client side and Server Push can be performed to refresh automatically when new data is entered into the...View answers

Questions : 8 :: What is called a session?

A session is an object which is used by a servlet and it is used to track user interaction with a web application across multiple HTTP requests.

Questions : 9 :: What is servlet mapping?


Servlet Mapping is an association mapping between servlet and a URL pattern. This is used to map servlets with the requests.

Questions : 10 :: What is a servlet context?

Servlet context contains servlet view of Web application in which servlet will be running. By using the context, Log events Obtain URL references to resources Set and Store...View answers

Questions : 11 :: Which interface should be implemented by all servlets?

Servlet interface should be implemented by all servlets.

Questions : 12 :: What is life cycle of Servlet?

Following is life cycle of Servlet: Loaded Initialized Destroy Unloaded

Questions : 13 :: What is the difference between Servlet Request and Servlet Context when calling a Request Dispatcher?

Relative URL can be called when Servlet Request is used and Relative URL is not used when using Servlet Context.

Questions : 14 :: What are the features added in Servlet 2.5?

Following are the features added in Servlet 2.5: Dependency on J2SE 5.0 Support for annotations Loading the class Several web.xml Removed restrictions Edge case...View answers

Questions : 15 :: When servlet is loaded?

A servlet can be loaded when: First request is made Auto loading and Server starts up There is a single instance that answers all requests concurrently which  saves memory Administrator...View answers

Questions : 16 :: When Servlet is unloaded?

A servlet is unloaded when: Server shuts down Administrator manually unloads

Questions : 17 :: What are the supporting protocol by HttpServlet ?

HttpServlet supports only HTTP and HTTPS protocol.

Questions : 18 :: What is called Session Tracking?

Session tracking is used to maintain a state on the series of requests from the same user for a given period of time.

Questions : 19 :: Why session tracking is needed?

Every HTTP request needs to be captured by HTTP protocol and for that, state is captured. Tracking of state is called session tracking.

Questions : 20 :: What are the types of Session Tracking ?

There are following types of session tracking: URL rewriting Hidden Form Fields Cookies Secure Socket Layer (SSL)

Questions : 21 :: What are the advantages of cookies?

Cookies are used to store long term information that can be maintained without server interaction. Small and Medium size data are kept in a queue.

Questions : 22 :: What is URL rewriting?

URL rewriting is one of the methods of session tracking in which additional data is appended at the end of each URL. This additional data identifies the session.

Questions : 23 :: What is servlet lazy loading?

A servlet container which does not initialize at the start up, this is known as servlet lazy loading.

Questions : 24 :: What is Servlet Chaining?

Chaining is one of the methods where out of one servlet is given to the second servlet. This chaining can happen for any number of servlets.

Questions : 25 :: What are the important functions of filters?

Following are the important functions of Filters: Security check Modifying the request or response Data compression Logging and auditing Response...View answers

Questions : 26 :: What are the functions of Servlet container?

Following are the functions of the Servlet container: Lifecycle management Communication support Multithreading support Declarative security JSP...View answers

Questions : 27 :: What is the difference between JSP and Servlets ?

JSP supports HTTP protocol which mainly used for presentation. But a servlet can support any protocol like HTTP, FTP, SMTP etc.

Questions : 28 :: What are all the ways for session tracking?

Following are the ways for session tracking: Cookies URL rewriting HttpSession Hidden form fields

Questions : 29 :: What is called Scriptlet?

A scriptlet contains any language statements, variables, expressions that can be valid in the page scripting language. Scriptlet is a part of generated servlet service method.

Questions : 30 :: What is the difference between Server and Container?

A server can provide service to the client and it contains one or more containers such as EJBs, Servlet, JSP containers. Containers hold set of objects.

Questions : 31 :: Can we refresh servlet in client and server side automatically?

On the client side, Meta http is used for refresh and server push is used for server side refresh.

Questions : 32 :: What is the difference between ServletConfig and ServletContext?

ServletConfig provides information about configuration of a servlet which is defined inside the web.xml file and it is a specific object for each servlet. ServletContext is an application specific...View answers

Questions : 33 :: What is Pure Servlet?

Pure servlet is servlet which is used to create java objects that can be implemented from javax.servlet.Servlet interface.

Questions : 34 :: What is the difference between Servlets and applets?

Servlets are used for server side config and it keeps on server. But, Applets are used for client side coding and it runs on client browsers.

Questions : 35 :: What is Generic Servlet class?

Generic servlet is the super class of all servlets. This class is extended by all other classes and it is protocol independent.

Questions : 36 :: What is Java Servlet?

Java servlet is used to provide secure access to the web based date. This can extend functionality present in the web servers. As it is platform and server independent, it is used for many...View answers

Questions : 37 :: What is String Tokenizer?

A String Tokenizer is used to break the string into tokens and the token value is passed as an argument in the constructor.

Questions : 38 :: What is HttpServlet and how it is different from GenericServlet?

HttpServlet extends from GenericServlet and inherits the properties of Genericservlet. HttpServlet defines a HTTP protocol servlet while GenericServlet defines a generic,...View answers

Questions : 39 :: How to get the current HttpSession object?

GetSession method is used to get the current HttpSession object on HttpservletRequest.

Questions : 40 :: What do you mean by Default initialization in Java Servlet?

This is one of the servlet initialization and it is initialized when it is called for the first time.

Questions : 41 :: What is Servlet Invoker?

Servlet Invoker allows web application to dynamically register new servlet definitions with the servlet tag in the /WEB-INF/web.xml.

Questions : 42 :: What is called Servlet mapping?

Servlet mapping maps URL patterns with the servlets. If there is a request from the client, servlet container decides on which application it needs to map.

Questions : 43 :: What are all the protocols supported by HttpServlet?

HttpServlet supports HTTP and HTTPS protocol.

Questions : 44 :: Which exception is thrown if servlet is not initialized properly?

Servlet Exception or Unavailable Exception is thrown if servlet is not initialized properly.

Questions : 45 :: Who is responsible for writing a constructor?

Container is responsible for writing constructor without arguments in servlet.

Questions : 46 :: What are all the advantages of Servlet over CGI?

Following are the advantages of Servlet over CGI: Cannot be run in an individual process. Servlet stays in the memory while requests. For every CGI request, you must load and start a CGI...View answers

Questions : 47 :: What are the different mode that servlets can be used?

Following are the modes that servlets can be used: Filter chains can be used to collect servlets together Support HTTP protocol Used for CGI based applications Dynamic generation of...View answers

Questions : 48 :: What are the uses of servlets?

Servlets are used to process and store data submitted by HTML form, dynamic content, handle multiple request concurrently and manage state information on top of stateless HTTP.

Questions : 49 :: Whether we can get deadlock situation in Servlets?

Yes, it can be achieved by writing doGet method in doPost method and writing doPost method in doGet method.

Questions : 50 :: What is the default HTTP method in the servlet?

Default method is GET method for HTTPservlet.

Questions : 51 :: Whether thread can be used in Servlets?

Yes, Single thread can be used in servlets.

Questions : 52 :: What exception should be thrown when servlet is not properly initialized?

Servlet exception or an Unavailable exception is thrown when it is not properly initialized.
More Question

Ask your interview questions on Servlets

Write Your comment or Questions if you want the answers on Servlets from Servlets Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---