File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes how can i acces database using jsp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how can i acces database using jsp? " Watch "how can i acces database using jsp? " New topic
Author

how can i acces database using jsp?

K Vidhyakar
Ranch Hand

Joined: Jul 10, 2005
Posts: 68
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: 68
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: 4968
    
    1

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can i acces database using jsp?