I have developed a few projects with servlets and can give you the following
advice. One big servlet defeats the current movement toward componentizing
applications. One big servlet is very tough to debug, update, and is not
practical to use in other projects because it is doing to many things when all
you want is one or two of the methods. As an example I designed a reporting
project with servlets. I too had to decide between one servlet or many. There
is a happy medium to be had here. I decided to move all database connection
pooling, calls and transactions into one servlet whose sole responsiblity was to
recieve sql, get a connection use the sql to make a query and return the
resultset. This servlet can then be used by other projects and is easily
updateable and debugged. I know if there is a problem with connections to the
database where the problem resides. Using this example with a little different
twist I created a shared object for all my servlets for this project to use to
generate the HTML for the reports since I knew the format was the same across
reports. If I have an HTML problem I know where to go to debug the problem.
The advantage of the shared object is that it reads the header, footer and side
navigation from HTML files so that non-Java programmers can update the pages
without getting into java code. The shared object also has one instance so that
all My servlets for this project use the same object to produce the same code,
so if the HTML changes then it changes across the site. I use this in most all
of my pages, sometimes I make it so that I pass a path to a header graphic, a
title and the body text and the shared object produces the page. I call this
Object Orientated Page design because all the Pages Inherit the objects page
design only they override the body, title and header graphic. The Reporting
code was kept in another servlet and I had a Servlet that dealt only with the
logic for all my reports. I used a switch statement to call the Report method
so that I could add another report without any problem by adding another line to
the switch statement and placing another method into the Report Servlet. As you
can see I divided this project into logical sections before I started, database
calls, HTML generation, Reporting logic, etc. I did not however create unique
servlets for each report and each connection to the database and HTML for each
report. This is the happy medium. I can use the HTML generation object for any
other project as well as the database object by just sending it the correct
parameters. I have components to build upon in my next application. I rarely
code an entire project any more I usually have database connections and
transactions already finished by a servlet and adapt my HTML generating object
and then all I left with is how to divide the logic of the site itself. I hope
this helps
Luther
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html