Most of the interviews include questions from core Java,servlets, JSP and EJB et cetera. Here in this article I am listing the 25 most asked questions on servlets. Servlet is not a vast topic so you can expect 7 to 10 questions from servlets in an interview. I am not providing the answers for these questions as you can simply search for the answers on the Internet.
If you are looking for code Java interview questions than I have already written a blog post for the same here
- How will you create a servlet?
- Is a servlet thread safe?
- Can a servlet only be created for HTTP protocol or can I write a servlet for the FTP protocol also?
- What are the minimum methods to be added in order to create a servlet?
- What are the various scopes available to a servlet?
- How to maintain concurrency in a servlet-based web application for the attributes and parameters?
- How will you end a session programmatically. What are the ways to specify the session timeout?
- What are the ways or session tracking in a servlet-based web application?
- How to specify the mapping for the URL of the servlet?
- What are the various parts of the URL of a servlet?
- What is the difference between servlet config and servlet context objects?
- What is the difference between GET and POST request?
- What is a filter with respect to servlet API and how can one chain the filters ?
- What is the difference between SendRedirect and Forward ?
- How will you write a HTML form which submits to a servlet?
- How will you pass initialization parameter to a servlet?
- How is a servlet file is stored in the web application server?
- What is the effect of making the service method synchronised?
- Are HTTPServl andetRequest and HTTPServletResponse classes or interfaces?
- What is the rule to specify the URL to forward/sendredirect methods?
- Why is there a call to service method of superclass in the servlet's service method?
- What is the life cycle of a servlet?
- What is meant by load on start-up that in web.xml?
- What will happen if two or more servlets are mapped to the same URL pattern in the web.xml file?
- Why there is no constructor defined in a servlet?
Do suggest If I have missed any important servlet interview question...