wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android forum!
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: 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
internet detective

Joined: May 26, 2003
Posts: 30136

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
Don't get me started about those stupid light bulbs.
subject: Basic Servlet Questions
Similar Threads
Help Tomcat5.5.7: Error in catalina
Servlet tag
Is there a way to Invoke a Servlet without having any Servlet Mapping Data in web.xml