This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Java in General and the fly likes Architecture for a  web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

Architecture for a web application

Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
Dear all,
I have the following doubts:
I was thinking about the following architecture for a
web based application -
having a single servlet which would receive all requests.
The rest of the modules of the application can be classes.
The servlet would do
* the authentication,
* log the result of the same (who logged in, when and if
the attempt is unsuccessful - log the same)
* the connection pool object would be in the servlet context
its getConnection() method would return a connection to the
database. This method would be passed to the method of the
class instantiated
* check if the user has rights to access the module asked for
(say - prepare a sales order)
* if the user has the rights, then it would insantiate the
sales order class and call the appropriate method of the
class depending on the type of the request (prepare a new
sales order, modify an existing sales order, query an order
in short the servlet would have a huge switch case which
would take care of the business logic. These would return
the html to the servlet and the servlet calls some template files , does patern matching and outputs the
html content to the browser in one out.println() statement
do you think that such big a servlet would cause performance
issues - one because all requests to the servlet would be
handled by this one servlet and another it would instantiate
the business class required and process it.
My main question is - will the classes be reused once they are
instantiated in RAM (on the next hit) OR are we completely at the
mercy of the garbage collector (ie if he leaves the class object
in RAM then and then only would it be reused, else the next request
for the same class would need the instantiation again)?
Because servlets are internally threaded, would the object
instantiated by one thread be available to another thread?
if yes, then do i need to take care about the mutation of public
variables in the class.
in the servlets case, i feel that i may get some benefits..
but that again is a feeling - no arguments in support
EXPERIENCE...I would like to know where would this approach go haywire.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

This has been covered in the Servlets Forum. Please don't post the same question in multiple forums.
I agree. Here's the link:
subject: Architecture for a web application
It's not a secret anymore!