wood burning stoves
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Basic Servlet Questions" Watch "Basic Servlet Questions" New topic

Basic Servlet Questions

Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 561

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

Joined: May 26, 2003
Posts: 33106

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link: http://aspose.com/file-tools
subject: Basic Servlet Questions
jQuery in Action, 3rd edition