Servlet is one of the very important topic of Java EE and also JAVA frameworks like Spring and Struts.This makes servlet interview questions as a hot topic in interviews. Here I am providing a list of servlet interview questions with answers which help you to tackle most of the interview questions related to servlets and web applications in java.
What is the difference between web application and enterprise application?.
What is the difference between web server and application server?
What is a servlet?
How many objects of a servlet is created?
What is the servlet lifecycle?
What is the difference between doGet() and doPost() method?
What are the tasks of servlet container?
What is ServletConfig object?
What is ServletContext object?
What is the difference between ServletConfig and ServletContext?
What is the difference between PrintWriter and ServletOutputStream?
What is the difference between GenericServlet and HttpServlet?
What is servlet collaboration?
What is the objective of RequestDispatcher interface?
What is web.xml file(deployment descriptor file)?
In web.xml file <load-on-startup>1</load-on-startup> is defined between <servlet></servlet> tag what does it means.
How can we create a deadlock condition on our servlet?
Do we need to override service() method?
For initializing a servlet can we use a constructor in place of init()?
How can you get the information about one servlet context in another servlet?
Why we need to implement Single Thread model in the case of Servlet.
What is SingleThreadModel interface?
What is session management?
How Cookies work in servlets?
How to notify an object in session when a session is expired?
Why do we have servlet filters?
Why do we have servlet listeners?
How can we upload the file to the server using servlet?
What is war file and how to create war file?
What are the annotations used in servlet?
What is the importance of welcome file list?
What are different ways for servlet authentication?
How to get IP address of client in servlet?
What is the use of attribute in servlets?
How to perform database connection and log4j integration in servlet?