Your Ad Here

Wednesday, December 31, 2008

Recent Servlets Interview Questions & Answer

Q : What is Servlets? What is the advantages of Servlet life cycle?
A : Servlets are modules that run within the server and receive and respond to the requests made by the client. Servlets retrieve most of the parameters using the input stream and send their responses using an output stream.
Servlets are used to the extend server side of functionality of a website. They communicate with various application on the server side and respond to the request made by the client.

Q : What is GenericServlet class?
A : The GenericServlet makes the writing servlets easier. To write a generic servlet, all you need to do is to override the abstract service method.

Q : What is the difference between a JavaBean from a Servlet?
A: Servlets are Java based analog to CGI programs, implemented by means of a servlet container associated with an HTTP server. Servlets run on the server side. Beans are reusable code components written in the Java that one can use in a variety of the programming environments. JavaBeans are used to Java what ActiveX controls are to Microsoft. Javabeans can run on server side, client side, within an applet etc

Q :Explain the servlet mapping?
A :Servlet mapping is the controls of how you access a servlet. It is recommended that you do not use the absolute URLs. Instead of usage of relative URLs should be done.
If you try to deploy the application with a different context root, you might have to change all the urls used in all the JSP programs. Relative URLs is the solution so that you can deploy your application with different context root with out changing the URLs.

Q: What is a Expression?
A : Expressions are act as a place holders for language expression, expression is evaluated each time the page is accessed. This shall be included in the service method of the generated servlet.

Q : What is the servlet context ?
A : The servlet context is an object that contains a information about the Web application and container. Using the context, a servlet can log events, obtain the URL and references to resources, and set of store and attributes that other servlets in the context can use.

Q : What are the different ways for session tracking?
A : There are different ways for session tracking
Cookies,
URL rewriting,
HttpSession,
Hidden form fields

Q : What are the type of protocols supported by HttpServlet?
A : Protocols extends the GenericServlet base on the class and provides an framework for handling the HTTP protocol. So, HttpServlet is the only supports HTTP and HTTPS protocol.

Q : What are the uses of Servlets?
A : Servlet can handle the multiple request concurrently and be used to develop high performance system
Servlets are used to process the client request.
A Servlet can be used to load balance among the serveral servers, as Servlet can easily forward.

Q : What is a Java Servlet?
A : A servlet is a Java technology-based Web component, managed by the container called servlet container or servlet engine, that generates the dynamic content and interacts with web clients via a request/response paradigm.

Q : What is the Servlet Interface?
A : The central abstraction is in the Servlet API is the Servlet interface. All servlets implement this interface, either directly one or, more commonly, by extending a class that implements it such as a HttpServlet. Servlets–>Generic Servlet–>HttpServlet–>MyServlet. The Servlet interface the declares, but does not implement, methods that manage the servlet and its communications with clients. Servlet writers provide some or all of these methods when developing a servlet.

Q :What are the differences between Applet and Servlet?
A : Applets are client side the components and runs on the web browsers Servlets are server side components that runs on the Servlet container.. Servlets have no GUI interface.

Q : What is GenericServlet class?
A : The GenericServlet is an abstract class that the implements the Servlet interface and the ServletConfig interface. In addition to the methods of declared in these two interfaces, this class also provides simple versions of the lifecycle methods init and destroy, and implements the log method declared in the ServletContext interface.

0 comments:

Your Ad Here