File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can i acces database using jsp?

 
K Vidhyakar
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
K Vidhyakar
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot..
wil i be able to call a normal class from any jsp file?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic