It's not a secret anymore!
The moose likes Servlets and the fly likes optimum number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "optimum number " Watch "optimum number " New topic

optimum number

eswar kumar
Ranch Hand

Joined: Oct 20, 2002
Posts: 98
what are the optimum no of servlets required for a project?
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Originally posted by eswar kumar:
what are the optimum no of servlets required for a project?

there's no optimum number of servlets. It all depends on how you architecture your application and how complex it is. You can use a single servlet to do *all* tasks if you want, but at the end you'll find yourself in a complete chaos

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33113

Some frameworks, like Struts, have one servlet. That servlet delegtes all responsibilities to other classes. That way the servlet doesn't grow in complexity and the separate actions stay manageable.

[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
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
so it depends on if you want to put all your code in servlets or not. if you do then each servlet should have a very specific task. if there are multiple pages that do the same sort of thing then they can be done in the same servlet, but very different pages should have their own. if you have shared functions accross different pages then you need to abstract the code into classes and use it accross the different servlets.

Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: optimum number
It's not a secret anymore!