You are on page 1of 2

Servlet interview questions

1. 2. 3. 4. 5.

Exception handling in Servlet and JSP specifications view answer Details about load on startup (load-on-startup tag) in Servlet ? view answer What's the difference between init() & init(ServletConfig) and Which is better ? view answer Servlet Life Cycle ? view answer Q. Can we override init() or init(ServletConfig) method of HttpServlet ? Which is better ? view

answer
6. Q. Can we override service method in HttpServlet ? view 7.

answer Q.What is the difference between init() and init(ServletConfig) ? view answer

view answer 9. What's the difference between init() & init(ServletConfig) in genericServlet ? view answer 10. Q.What is the difference between ServletContext and PageContext? view answer
8. Q.How to upload an File/image from servlet/jsp into server from clients machine? 11. Q.What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?

view answer
12. Q.Difference forward() and response.sendRedirect() . view

answer 13. Q.Can we use the constructor, instead of init(), to initialize servlet? view answer 14. Q.Explain the life cycle of Servlet? view answer 15. Q.Why don't we write a constructor in a servlet? view answer
16. Q.When we don't write any constructor for the servlet, how does container create an instance of servlet?

view answer
17. Q.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()? view

answer

18. Q.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? view answer 19. Q.Request parameter How to find whether a parameter exists in the request object? view answer 20. What is new in ServletRequest interface ? view answer 21. Q.Given the request path below, which are context path, servlet path and path info? /bookstore/education/index.html view answer 22. Q.When a client request is sent to the servlet container, how does the container choose which servlet to invoke? view answer 23. Q.What is servlet container? view answer 24. Why IllegalStateException in jsp/servet? view answer 25. Q.How do I upload a file in a servlet app? view answer 26. Q.What's the difference between response.sendRedirect() and requestDispatcher.forward() ? view

answer
27. Q.How do I implement security for my web application ? view

answer 28. Q.How can I use servlets with protocols other than HTTP, e.g. FTP? view answer 29. Q.What happens if i call destroy() from init()? view answer 30. Q.Why can't a container call constructor having parameters? view answer

31. Q.Why do servlets have an init method? Can't we make use of the servlet constructor for initialization?

view answer
32. Q.Explain the life cycle methods of a Servlet. view

answer 33. Q.Explain the directory structure of a web application view answer 34. Q.What are the common mechanisms used for session tracking? view answer 35. What is load-on-startup in servlet ? view answer
36. Q. What is the difference between the getRequestDispatcher(String) and getNamedDispatcher(String)

methods in the ServletContext Class? view answer 37. Q: What is the difference between Difference between doGet() and doPost()? view answer 38. Q. What is the difference between ServletContext and ServletConfig? view answer 39. Q: What is the difference between HttpServlet and GenericServlet? view answer 40. Q.What is the difference between the getRequestDispatcher(String path) method of ServletRequest interface and ServletContext interface? view answer

You might also like