| Author |
how can i acces database using jsp?
|
K Vidhyakar
Ranch Hand
Joined: Jul 10, 2005
Posts: 66
|
|
Hi friends, im new to jsp. i want to access database and display the result in the jsp page. how can i do that? is there anw way to access it without calling the bean?
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
You can work directly with a database from your JSPs but it is not recommended. Moving the database code out of your servlet and into a bean or some other Java class makes it much easier to test and re-use. That being said, perform a Google search for "JDBC TUTORIAL" and you will find plenty of code samples.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
K Vidhyakar
Ranch Hand
Joined: Jul 10, 2005
Posts: 66
|
|
thanks a lot.. wil i be able to call a normal class from any jsp file?
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Originally posted by K Vidhyakar: thanks a lot.. wil i be able to call a normal class from any jsp file?
If by normal class, you mean a packaged java class that is made available to the web application (in either WEB-INF/classes, WEB-INF/lib, or one of the shared directories), yes.
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
You can do regular JDBC in a JSP page, but it will get messy, and maintaining that code will be difficult. If it's all proof of concept stuff as you're learning, I guess it's okay. Here's a little tutorial on MVC and how JSPs should fit into a proper application design. You might find it interesting: http://www.technicalfacilitation.com/get.php?link=whatismvc Cheers! -Cameron McKenzie www.pulpjava.com
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
 |
|
|
subject: how can i acces database using jsp?
|
|
|