-1

Can u plz tell me wats wrong in using jsp to connect to a databse..

Votes + Comments
JSP is not for database conectivity, servlet is the correct tool
0

There is nothing wrong by putting the database connection in the JSP, but you have to create a new database connection and query for every page you creates. This will reduse the performance and response on server. This is one of the problems. Instead you could create a connection class and put it into application scope and the connection will be made when server is started. This is done only once. Then it is available for all objects that uses table info from the database.

0

There is nothing wrong by putting the database connection in the JSP

Ever heard of MVC (Model-View-Controller)? Well then you may want to google out something on the subject and learn new things

0

MVC (Model View Controller) That is Model this part holds the data between view and database or files, View this is the JSP, GUI or other interface presentet to the user, Controller this is the part that sends the messages of what to do with the data when user clicks a component or some changes happens on the database table. Please read more about this topic at SUN's pages.

0

Can u plz tell me wats wrong in using jsp to connect to a databse..

Do you have some source code?

1

There is nothing wrong by putting the database connection in the JSP,

Yes there is. You have obviously never worked on anything that lasted more than a few days, or ever needed to be expanded or improved or fixed. Scriptlets are a maintenance nightmare. At the very least use a bean.

but you have to create a new database connection and query for every page you creates.

Hopefully you mean retreiving one from a Connection pool and not actually creating one with every query. That would be a performance nightmare.

This will reduse the performance and response on server. This is one of the problems.

(I guess you didnt mean using a pool.) Not with a Connection Pool, and every web container (which you must be using to use JSP) has a connection pool, so no problem.

Instead you could create a connection class and put it into application scope and the connection will be made when server is started. This is done only once. Then it is available for all objects that uses table info from the database.

Yet another bad suggestion. A static, single connection used by a dynamic (God I hate that word) threaded application? What happens when one thread calls rollback directly before another thread was about call commit? Or the other way around?


Connection Pools, Beans, and a properly implemented layered approach. Everything presented here is ....... well, I don't think I really need to say it.

Edited by masijade: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.