Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Servlets Interview Questions and Answers

  Difficulty Level: AllBeginnerIntermediateExperienced/Expert

Ques 1. What is Servlet?

Ques 2. Why is Servlet so popular?

Ques 3. What is servlet container?

Ques 4. When a client request is sent to the servlet container, how does the container choose which servlet to invoke?

Ques 5. If a servlet is not properly initialized, what exception may be thrown?

Ques 6. Given the request path below, which are context path, servlet path and path info?

Ques 7. What is filter? Can filter be used as request or response?

Ques 8. When using servlets to build the HTML, you build a DOCTYPE line, why do you do that?

Ques 9. What is new in ServletRequest interface ? (Servlet 2.4)

Ques 10. Request parameter How to find whether a parameter exists in the request object?

Ques 11. How can I send user authentication information while making URL Connection?

Ques 12. The code in a finally clause will never fail to execute, right?

Ques 13. What mechanisms are used by a Servlet Container to maintain session information?

Ques 14. Difference between GET and POST

Ques 15. What is session?

Ques 16. What is servlet mapping?

Ques 17. What is servlet context ?

Ques 18. Which interface must be implemented by all servlets?

Ques 19. Explain the life cycle of Servlet.

Ques 20. When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

Ques 21. Why don't we write a constructor in a servlet?

Ques 22. When we don't write any constructor for the servlet, how does container create an instance of servlet?

Ques 23. Once the destroy() method is called by the container, will the servlet be immediately destroyed? What happens to the tasks(threads) that the servlet might be executing at that time?

Ques 24. What is the difference between callling a RequestDispatcher using ServletRequest and ServletContext?

Ques 25. Why is it that we can't give relative URL's when using ServletContext.getRequestDispatcher() when we can use the same while calling ServletRequest.getRequestDispatcher()?

Ques 26. What is the difference between an application server and a Web server?

Ques 27. What are advantages of servlets over CGI?

Ques 28. What are the two important APIs in Servlets?

Ques 29. Can you explain in detail "javax.servlet" package?

Ques 30. What's the use of ServletContext?

Ques 31. What's the difference between GenericServlet and HttpServlet?

Ques 32. What’s the architecture of a Servlet package?

Ques 33. Why is HTTP protocol called as a stateless protocol?

Ques 34. What are the different ways we can maintain state between requests?

©2023 WithoutBook