Servlet Interview Questions

October 2nd, 2007 Admin Posted in Servlet interview questions No Comments »

The java.servlet.Servlet interface defines 3 methos known as life-cycle method.

1. public void init(ServletConfig config) throws ServletException: servlet is constructe, then initialized with the init() method.
2. public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException: any request from client are handled initially by the service() method before delegating to the doXxx() methods in the case of HttpServlet.
3. public void destroy(): Servlet is removed from service, destroyed with the destroy() method, then garbage collected and finalized.

What is the difference between doGet() and doPost()?

doGet() mthod is limited with 2k of data to be sent, and doPost() mehtod doesn’t have this limitation. A request string for doGet() looks like the following: http://www.google.com/svt1?p1=v1&p2=v2&…&pN=vN. doPost() method call doesntneed a long texttail after a servlet name in a request. All parameters are stored in a request itself, not in a request string, and its impossible to guess the data transmitted to a servlet only looking at the request string.

HttpServlet and GenericServlet: GenericServlet has a service() method aimed to handle requests. HttpServlet extends GenericServlet and addes support for doGet(), doHead() methods (HTTP 1.0) plus doPut(), doOptions(), doDelete(), doTrace() methods. Both these classes are abstract.

ServletContext and ServletConfig: ServletContext defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. The ServletContext object is contained within the ServletConfig object, which the web server provides the servlet when the servlet is initialized.

ServletConfig: the object created after a servlet is instantiated and its default constructor is read. It is created to pass initialization infomation to the servlet.

AddThis Social Bookmark Button

Frequently Asked Questions on Servlets Concepts

August 16th, 2007 Admin Posted in Servlet interview questions, Servlets, Servlets Frequently Asked Questions No Comments »

1. How do u deal property files in servlet?
2. What methods do u use in Servlet - Applet communication ?
3. What are the types of Servlet ?
4. Difference between HttpServlet and Generic Servlets ?
5. Difference between doGet and doPost ?
6. What are the methods in HttpServlet?
7. What are the types of SessionTracking?
8. What is Cookie ? Why is Cookie used ?
9. If my browser does not support Cookie,and my server sends a cookie instance What will happen ?
10. Why do u use Session Tracking in HttpServlet ?
11. Can u use javaScript in Servlets ?
12. What is the capacity the doGet can send to the server ?
13. What are the type of protocols used in HttpServlet ?
14. What is meant by a servlet ?
15. What are the types of servlets ? Explain
16. What is the different between a Servlet and a CGI?
17. What is the difference between 2 types of Servlets ?
18. What is the type of method for sending request from HTTP server ?
19. What are the exceptions thrown by Servlets ? Why ?
20. What is the life cycle of a servlet ?
21. What is meant by cookies ?
22. What is HTTP Session ?
23. What is the difference between GET and POST methods ?
24. How can you run a Servlet Program ?
25. How to commuincate between an applet and a servlet ?
26. What is a Servlet-to-Servlet communcation ?
27. What is Session Tracking ?
28. What are the security issues in Servlets ?
29. What is HTTP Tunneling?
30. How do you load an image in a Servlet ?
31. What is Servlet Chaining ?
32. What is URL Rewriting ?
33. What is context switching ?
34. How will you pass values from HTML page to the Servlet ?
35. What is Servlet API used for conneting database ?
36. In servlets, we are having a web page that is invoking servlets? Username and password ? which is cheks in the database ? Suppose the second page also If we want to verify the same information whethe it will connect to the database or it will be used previous information?
37. What are virtual functions ?
38. Write down how will you create a binary Tree ?
39. What are the traverses in Binary Tree ?
40. Write a program for recursive Traverse ?
41. What are session variable in Servlets ?
42. What is client server computing ?
43. What is meant by Servelet? What are the parameters of the Service Method ?
44. What is meant by Session ? Tell me something about HTTPSession Class ?
45. How do you invoke a Servelt? What is the difference in between DoPost and doGet methods ?
46. What is the difference in between the HTTPServlet and Generic Servlet?
47. Expalin their methods ? Tell me their parameter names also Have you used threads in Servelet ?
48. How do you load an Image in a Servlet ?
49. Explain Servlet Life cycle?
50. Why do you go for servlet rather than CGI

AddThis Social Bookmark Button

How does HTTP Servlet handle client requests?

March 8th, 2007 Admin Posted in Servlet interview questions No Comments »

An HTTP Servlet handles client requests through its service method. The service method supports standard HTTP client requests by dispatching each request to a method designed to handle that request.

AddThis Social Bookmark Button