then the database access bean must be of application scope right.
We follow a servlet-centric design approach @ our place.
So there's no database specific code in the jsp. It is used only for presentation.
There can be a "view" object which contains the data to be displayed..ie the display s'd be already filled in.
The jsp can fetch it from the request.
identify the business objects specific to your application.
Once you have done that define method for that .
Eg : Reservation
so possible methods/operations can be save, update , delete..so on.
Associate a command with the JSPs ( have ids for save/update/delete) pass that id from the jsp to the servlet while submitting.
The servlet can do a look up and find out the Business object responsible for that operation.
Let all Business objects implement a interface which say has a signature like this.
void handleRequest(request,response) throws RequestHandleException{
//get the id passed from the request.
switch(id){
if (save)
call BusinessLogic.save()
if (update)
call BusinessLogic.save()
....
}
}
In business logic do database specific stuff and populate the View Object with the data.
put this view object into the request(HttpRequest).
Eg:
class ViewReservationObject{
getters
setters
}
So when the business method exits, the control is back to servlet, it s'd know the next jsp to be displayed(targer jsp)
so the servlet can use the request dispatcher to forward the request to that jsp. So now the view object is available with the request.
If i'm not clear here, buy
Web development with
Java server pages..Duane K fields et all.
It's probably the best jsp book out in the market.
rgds
karthik.