i am creating an online shopping cart softwre using jsp.. i want to know which is the best way to check userid and password(that is how can i interact jsp with database (obviously using jdbc))to check user ids and to store new user record...i am new to jsp.. thanx
Best way is to not do it in the JSP at all Have the login request (and every other request) sent to a servlet that (through other classes) does the database interaction and prepares the output data for the JSP (and then forwards the request with that data to the JSP for display). Use the JSP ONLY for displaying data, never for business logic. Java code should be limited to the absolutely necessary only like a little loop or counter (though you might consider custom tags for those).
hiiiii i think Jeroen Wenting is right.. but i would like to go one step further... i.e. i will like to disaply all data and take input from the users using a JSP page.. i.e. it will work as VIEW.. and all JSP in my application would call one servlet (name it Controller).. with one String as key as hidden value based on which the Controller will another servlet for specific purposes which wil have the bussiness logic like connecting to databases and validating user etc etc and then this will also return a String as key to another servlet (or same servlet, if your aplication is not large).. depending on which the servlet will decide response is to be commited to which JSP... which will in turn display the data.. This is a good example of MVC architecture.. you can design your own more patterns like this or even cosider STRUTS for such an application if you want... Thanks Amit
****************************<br />In 24 hrs Earth rotates once on its Axis.
subject: which is the best technique to connect jsp with database