Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Basic Servlet Questions

 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Praveen Kumar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34422
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic