• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlets

 
bhagya modukuri
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have some doubts in servlets...please go thro them & reply if possible...

1. explain reg embeddable servlet engines???
2. when does a ServletException occur???
3. how does the client specify that it likes to receive only the headers of the response instead of the entire response???
4. y do we need to save a reference to the ServletConfig object in our program by stating super.init(config) in our init method ???
5. how does the user know if a servlet has been destroyed or not???

 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by bhagya modukuri:
1. explain reg embeddable servlet engines???

Can you be more specific?
2. when does a ServletException occur???

When you throw one. Why would you throw one? Well, you generally throw exceptions because something goes unexpectedly wrong. You can configure the servlet container to go to an error page when an exception gets thrown.
3. how does the client specify that it likes to receive only the headers of the response instead of the entire response???

The HTTP request invokes the HEAD method rather than GET. See RFC 2068. You generally don't need to bother with this since the HttpServlet service() implementation handles it for you.
4. y do we need to save a reference to the ServletConfig object in our program by stating super.init(config) in our init method ???

The Servlet implementation stores the reference away for later retrieval using getServletConfig(). You don't need to store the reference yourself.
5. how does the user know if a servlet has been destroyed or not???

The "user" as in "site user" doesn't need to know. As far as he is concerned the servlet is always there, because the servlet engine will instantiate it when/as needed.
The "user" as in "developer" can override the destroy() method to free up resources (database connections, network connections, open files...). Other than that he, too, doesn't need to know whether a servlet has been instantiated or not.
HTH
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic