Servlet interview questions
- Exception handling in Servlet and JSP specifications
- 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
- Q. Can we override service method in HttpServlet ?
- Q.What is the difference between init() and init(ServletConfig) ? view answer
- Q.How to upload an File/image from servlet/jsp into server from clients machine? view answer
- What's the difference between init() & init(ServletConfig) in genericServlet ? view answer
- Q.What is the difference between ServletContext and PageContext?
- Q.What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?
- Q.Difference forward() and response.sendRedirect() . view answer
- Q.Can we use the constructor, instead of init(), to initialize servlet?
- Q.Explain the life cycle of Servlet? view answer
- Q.Why don't we write a constructor in a servlet? view answer
- Q.When we don't write any constructor for the servlet, how does container create an instance of servlet? view answer
- 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
- 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
- Q.Request parameter How to find whether a parameter exists in the request object?
- What is new in ServletRequest interface ? view answer
- Q.Given the request path below, which are context path, servlet path and path info?
/bookstore/education/index.html view answer
- Q.When a client request is sent to the servlet container, how does the container choose which servlet to invoke? view answer
- Q.What is servlet container?
- Why IllegalStateException in jsp/servet? view answer
- Q.How do I upload a file in a servlet app? view answer
- Q.What's the difference between response.sendRedirect() and requestDispatcher.forward() ? view answer
- Q.How do I implement security for my web application ? view answer
- Q.How can I use servlets with protocols other than HTTP, e.g. FTP? view answer
- Q.What happens if i call destroy() from init()?
- Q.Why can't a container call constructor having parameters? view answer
- Q.Why do servlets have an init method? Can't we make use of the servlet constructor for initialization? view answer
- Q.Explain the life cycle methods of a Servlet.
- Q.Explain the directory structure of a web application view answer
- Q.What are the common mechanisms used for session tracking?
- What is load-on-startup in servlet ? view answer
- Q. What is the difference between the getRequestDispatcher(String) and getNamedDispatcher(String) methods in the ServletContext Class? view answer
- Q: What is the difference between Difference between doGet() and doPost()?
- Q. What is the difference between ServletContext and ServletConfig?
- Q: What is the difference between HttpServlet and GenericServlet?
- Q.What is the difference between the getRequestDispatcher(String path) method of ServletRequest interface and ServletContext interface?
!!! Servlet interview questions !!!
Q.How can I use servlets with protocols other than HTTP, e.g. FTP?
The javadocs for javax.servlet.Servlet and GenericServlet make it sound as if protocols other than HTTP can be used simply by extending GenericServlet, and implementing the methods that deal with the protocol, much like HttpServlet does for HTTP. That is not the case. The protocol needs to be supported by the servlet engine (which does all the network handling for the servlet), and no servlet engine exists that supports anything other than HTTP(S). Adding a different protocol would be a big project, especially since other protocols don't have the same request/response nature of HTTP. If you find yourself contemplating such a project, post your requirements to the Servlet forum, and a better solution will probably be suggested.
For JSPs, the specification says "Most JSP pages use the HTTP protocol, but other protocols are allowed by this specification.". Since a non-HTTP JSP implementation would depend on a non-HTTP servlet implementation, that too is just a theoretical possibility.
(Note that all of this has nothing to do with a servlet's ability to be a client for other protocols. E.g., by using the JavaMail or Jakarta Commons Net APIs a servlet can access SMTP and FTP servers without problems.)
Suggested Jobs More Jobs >>