Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes Basic Servlet Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Basic Servlet Questions" Watch "Basic Servlet Questions" New topic
Author

Basic Servlet Questions

Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 507

Hi All,
I'm new to Servlets.need assistance for the below queries.

1> Can we create a Servlet without init() and destroy() methods ?if so,will the servlet run without errors ?
2> how do 2 web servers communicate with each other?

--
Deepak Lal


When The Going Gets Tougher,The Tougher gets Going
Praveen Kumar
Ranch Hand

Joined: Nov 06, 2006
Posts: 133
Hi Deepak,


we should have init() to create and destroy() to destroy the servlet.

According Servlet specification we should have.

But Containers will take care of this things.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Deepak,
1) HttpServlet (or more precisely, its superclass), implement init and destroy. You only need to override them if you have something specific that needs to be done. Init is useful for initializing configuration parameters and the like. I've never had cause to override destroy.

2) Web servers don't communicate with each other directly. A client (browser) makes requests to both and the client combines the information into a web page.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
 
subject: Basic Servlet Questions